3

I'm getting "System.Data.SQLite.SQLiteException: Unable to open the database file." when I attempt to access the database to save a record upon the "first" opening of my program.

Here's the thing, it works fine when debugging locally in Visual Studio, but stops working when I package the program in an installer, and then install the program somewhere.

I was guessing that it was the location of the database, which I just have set at database.s3db without a path, because it is stored next to the program's exe, but how could that cause problems?

I'm at a loss, any further ideas or suggestions for solving this problem would be greatly appreciated.

2 Answers 2

7

Maybe you are installing the program in a folder which the user doesn't have write permissions so cannot modify the database file.

Sign up to request clarification or add additional context in comments.

5 Comments

That was exactly it. Why is it that ProgramFiles has places that can't be modified? Don't most programs modify their own files?
@CODe, no, starting from Windows Vista only the administrator have write permissions to the program files folder. You have to use the corresponding c:\users\AccountName folder to store user specific files.
´Why is it that ProgramFiles has places that can't be modified?´ In order to make it more difficuilt for malware (virus, trojan) to install itself
@CODe: I strongly disagree - this is actually one of the few things MS got right in Vista and subsequent versions. UNIX-like systems have been allowing regular users write access only to their home directories by default since forever, and that is a Good Thing. It prevents malicious software from doing Bad Stuff and dumb users from doing Dumb Stuff.
If the database is to be shared among all users of a system, you can put it in the All Users Application Data folder.
-1

Please update your DataSource Format like this :

@"C:\Users\Mehmeto\Documents\Visual Studio 2015\Projects\......\bin\myDB.sqlite";

Where the directory points to where your project is located.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.