1

I am trying to deploy a simple windows desktop app using a SQL Server database.sdf file. I have followed the steps in this walkthrough about 10 times and I still am having problems. http://msdn.microsoft.com/en-us/library/bb546200.aspx

In my app.config file my connection string is this:

<add name="VendorTracker_2._0.Properties.Settings.Database1ConnectionString"
     connectionString="Data Source=C:\Users\Eamon\Documents\Visual Studio 2008\Projects\VendorTracker 2.0\VendorTracker 2.0\Database1.sdf"
     providerName="Microsoft.SqlServerCe.Client.3.5" />

According to the walkthrough, the windows installer should recognize that I am using a SQL Server CE .sdf file and create a new connection string:

<add name="VendorTracker_2._0.Properties.Settings.Database1ConnectionString1"
     connectionString="Data Source=|DataDirectory|\Database1.sdf"
     providerName="Microsoft.SqlServerCe.Client.3.5" />

It does add this connection string to the app.config file. Now I have both connection strings listed in the app.config file. When I deploy the app onto my development computer, it works fine, no problem connecting to the .sdf file.

But when I copy the install folder and everything inside of it to a different "testing" computer I get the following error when I try to run the app:

The path is not valid. Check the directory for the database. [ Path=C:\Users\MyName\Documents\Visual Studio 2008\Projects\VendorTracker 2.0 Database1.sdf].

The app continues to run but there is no data and It will not allow me to save anything to the database.

Why doesn't the .sdf file get deployed with the connection string:

Data Source=|DataDirectory|\Database1.sdf

like it is suppose to? Driving me nuts. I have tried everything. Has anyone successfully used a SQL Server CE .sdf file with a stand alone windows desktop app? I know they are used a lot for mobile devices but that shouldn't make a difference. Please help.

Oceantrain

3
  • Did you try removing the non-relative path string? Commented Nov 13, 2010 at 5:10
  • Yes I removed the non relative path string and just left the |Data Directory| string. Still no luck. Commented Nov 13, 2010 at 15:57
  • What's the problem if you only have the |Data Directory| path? Commented Nov 13, 2010 at 20:45

1 Answer 1

1

You must change the connection string manually. Also, consider carefully where you place the file, as not all places are writable

Sign up to request clarification or add additional context in comments.

1 Comment

Why doesn't click once deployment "place" the file in the appropriate place to begin with? I don't understand why it's so difficult to deploy a simple windows app with an .sdf file and install it on a test computer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.