2

I have SQL Ce db in my app, which is included in my app directory. While debugging its OK, but when published and run with setup.exe, it retrieves "file not found" in temporary directory the app is ran from. I would like to run from standard location, but I dont know how to change it.

I am using this string:

SqlCeConnection connection = new SqlCeConnection("Data Source=database.sdf;Persist Security Info=False;");

When I run setup.exe, the app never starts, stating that in its temporary directory the db file was not found. When I run app.exe, it works. I do not understand it...:(

EDIT: I can see that in the VS project settings, there is connection string and there is "Data Source=|DataDirectory|\Database.sdf"

The path should be something like local directory? Thanks!

1 Answer 1

1

Build your connection string dynamically. Something like this:

string connString = string.Format("Data Source={0}; Persist Security Info=False;",
    Path.Combine(Application.StartupPath, "database.sdf"));
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.