CODe
CODe

Reputation: 2301

C# .net -> SQLite error: Unable to open the database file

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.

Upvotes: 3

Views: 7882

Answers (2)

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.

Upvotes: -1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

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

Upvotes: 7

Related Questions