I have a sqlite database and I want to connect from my C# program using a password for the database. I am using Navicat and I set encrypt database file with password “test”
and then by code my connection string is:
_connection = new SQLiteConnection("Data Source=MedExpress.db;Version=3;Password=\"test\";");
or
_connection = new SQLiteConnection("Data Source=MedExpress.db;Version=3;Password=test;");
But this does not work.
The error is: File opened that is not a database file
file is encrypted or is not a database
I can connect to the database without a password like this:
_connection = new SQLiteConnection("Data Source=MedExpress.db;Version=3;");
My question is how can I set a password to a sqlite database and connect from C# program using System.Data.SQLite
This is the connection string with password
As you stated that you use navicat to set the sqlite encryption.
Encryption means that you’ve encrypted the database it’s different from setting a password to a database..
in setting a password to a database try this code..
Remove the encryption first ..