1

I manage to finish my project and publish it for deployment on other machines. My C# WPF application have SQL Server CE as its backend database. I wanted the database to be able to work in other machine that have no SQL Server CE installed. I publish it using clickonce, the publish was successful. However when I run it on other machines, and tries to open the database there is an error prompt that said 'database file cannot be found. Check the path to the database [Data Source=D:db.sdf]. I followed the tutorials on clickonce by mdsn, Microsoft and by other people, the result is always the same. The local database cannot be detected.

1 Answer 1

1

D:db.sdf is not created by ClickOnce, you must have changed something. ClickOnce by default installs data that is included in a project to a directory in the app folder, and sets the DataDirectory app domain value to the path to this directory. In your application you should use something like

SqlConnection("Data Source=|DataDirectory|db.sdf;...")

Note that DataDirectory may not be writable by users. If you want users to save data you should copy |DataDirectory|db.sdf to some place writable like

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
Sign up to request clarification or add additional context in comments.

Comments

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.