accdb file read only when installed with VS2010 setup project
I have created a program that uses an accdb file. I have also created a setup project for deployment of said program. However, I am having difficulties with the accdb file being ready only in Microsoft Vista.
First I had the accdb file installed into the DataDirectory, but realized that if you need changes made to files the Program Files location is not the place to install files.
SO I attempted to i开发者_StackOverflow社区nstall into the ProgramData directory but the accdb file is still read only. I then attempted to install into the users directory, but can not get the connection string in the app.config file to be correct.So ultimately, my questions are:
1. Where do I need to install an accdb file so that it is not read only? 2. How do I configure that directory in the FileSystem within VS2010? 3. What should the connection string in the app.config look like?I would like this to work in XP, Vista, and W7 if possible. It would be okay to create multiple setup projects if need be for it to work across multiple OS.
You should install the db file to the LocalAppDataFolder.
It seems you've tried this...
But can not get the connection string in the app.config file to be correct.
Rather than set the connection string at design time you should set the string at runtime
From ErikEJ's answer to a similar question
string fileName = System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"SqlCe35AddinStore.sdf");
string connString = string.Format("Data Source={0};", fileName);
精彩评论