Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am developing a small windows form with sqlCE. i made an installer to deploy it to another machine. I added the MyDB,sdf to the Application Folder. but when i run the application it gives me following error.

Access to the database file is not allowed. [ File name = MyDB.sdf ]

i checked the folder in program file(86) and it contain the .sdf file but can't figure it out what is the problem.

my connection string is string ConString = @"Data Source=MyDB.sdf";

any idea what i am doing wrong?
Posted

1 solution

"Program Files" in Windows is protected, so normal users cannot write there, your applications will probably work with an administrator user.

Change the data folder path for your database to somewhere where all users have permission to write.
 
Share this answer
 
Comments
SR.Rizwan 10-Aug-12 2:50am    
how can i change the folder and specify it in the installer?
Mehdi Gholam 10-Aug-12 3:08am    
Consult your installer documentation, for your code make the database path a configuration point (instead of hard coding).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900