0

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 install 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.

Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
Voyagr12
  • 1
  • 2
  • Looks very similar to this also [unanswered question](http://stackoverflow.com/questions/4305782/where-to-deploy-a-database-file-to-have-read-write-privileges) – Conrad Frix Jan 31 '11 at 22:53
  • yes, i did come across that, but it was unanswered so didnt help much. – Voyagr12 Feb 01 '11 at 00:27

1 Answers1

0

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);
Community
  • 1
  • 1
Conrad Frix
  • 51,984
  • 12
  • 96
  • 155
  • so it is acceptable to not put the connection string in the app.config file – Voyagr12 Feb 01 '11 at 00:27
  • I just attempted to remove the connection string from the app.config file and insert it into the open event of my startup form. However, now when i try to build it is giving me all sorts of errors that it can not find the dataset. – Voyagr12 Feb 01 '11 at 00:51