Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server CE error Access to the database file is not allowed

I have a WPF application and I'm using SQL Server CE on it. It works fine when debugging with Visual Studio, but when I install the application in any computer, an error message is shown saying:

Access to the database file is no allowed

and the path of my database(usually the folder where the application was installed C:/ProgramFiles).

like image 842
user1517951 Avatar asked Feb 28 '26 20:02

user1517951


1 Answers

The folders C:\program files or C:\program files (x86) cannot be used to store writable elements of an application like a database file. This is a security change made in Vista and in Win7 (UAC).

You should choose a different location (MyDocuments, ProgramData or else) where to store your database file during setup.

When you debug in Visual Studio, you are running your application inside the Solution Directory and subfolder bin\debug where you have read/write permissions.

like image 76
Steve Avatar answered Mar 02 '26 15:03

Steve



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!