1

I have created a Winforms app that writes all data to a SQL Server CE database. I am able to successfully install the app but when I try to read or write data, it tells me that it cannot open the connection. This only happens on PC's other than the one I created the program on. Nothing is hardcoded.

Does anyone have any suggestions?

Thank you

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
pls3399
  • 53
  • 6

1 Answers1

1

Windows will fight you with permission issues for locating the database in the Program Files directory. It doesn't belong there.

Consider moving the database to your own folder in this root folder:

Environment.SpecialFolder.ApplicationData

Obviously, the connection string needs to reflect that folder path.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
  • How would I do this? I understand I would need to change my connection string to "Data Source= Environment.SpecialFolder.ApplicationData.LaZSolutions.sdf", but how do I setup everything around it? Thanks for pointing me in the right direction. – pls3399 Nov 27 '13 at 17:00
  • @user2379048 See [Create sql server compact file in appdata folder](http://stackoverflow.com/a/7640142/719186) – LarsTech Nov 27 '13 at 17:24