Cannot deploy application with SQL Server CE database.file
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"
connectionStrin开发者_运维技巧g="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
You must change the connection string manually. Also, consider carefully where you place the file, as not all places are writable
精彩评论