How to use password protected sqlite database?
-
I have a sqlite database protected by password and I can't use it in query. How should I modify the code to read data from a protected database?
private static string conn = @"Data Source=aplicatie.db;Pooling=true;FailIfMissing=false;Version=3;Password=example";
An example with query:
string selectutilizator = "SELECT username,prenume,licenta FROM accounts";
SQLiteCommand selcom = new SQLiteCommand(selectutilizator, Conexiune.getConnection());
selcom.CommandType = CommandType.Text;
using (SQLiteDataReader read = selcom.ExecuteReader())
{
if (read.Read())
{
SimulatorManager.Nume = (string)read["username"];
SimulatorManager.Prenume = (string)read["prenume"];
SimulatorManager.Utilizator = SimulatorManager.Nume + " " + SimulatorManager.Prenume;
}
}Error is:
file is encrypted or is not a database
-
I have a sqlite database protected by password and I can't use it in query. How should I modify the code to read data from a protected database?
private static string conn = @"Data Source=aplicatie.db;Pooling=true;FailIfMissing=false;Version=3;Password=example";
An example with query:
string selectutilizator = "SELECT username,prenume,licenta FROM accounts";
SQLiteCommand selcom = new SQLiteCommand(selectutilizator, Conexiune.getConnection());
selcom.CommandType = CommandType.Text;
using (SQLiteDataReader read = selcom.ExecuteReader())
{
if (read.Read())
{
SimulatorManager.Nume = (string)read["username"];
SimulatorManager.Prenume = (string)read["prenume"];
SimulatorManager.Utilizator = SimulatorManager.Nume + " " + SimulatorManager.Prenume;
}
}Error is:
file is encrypted or is not a database
-
I have a sqlite database protected by password and I can't use it in query. How should I modify the code to read data from a protected database?
private static string conn = @"Data Source=aplicatie.db;Pooling=true;FailIfMissing=false;Version=3;Password=example";
An example with query:
string selectutilizator = "SELECT username,prenume,licenta FROM accounts";
SQLiteCommand selcom = new SQLiteCommand(selectutilizator, Conexiune.getConnection());
selcom.CommandType = CommandType.Text;
using (SQLiteDataReader read = selcom.ExecuteReader())
{
if (read.Read())
{
SimulatorManager.Nume = (string)read["username"];
SimulatorManager.Prenume = (string)read["prenume"];
SimulatorManager.Utilizator = SimulatorManager.Nume + " " + SimulatorManager.Prenume;
}
}Error is:
file is encrypted or is not a database
As Richard says, the wrong password is the most obvious problem. Other possibilities are: 1) It's not an SqLite database at all - ".db" is a common enough extension that it could be a different application 2) It's SqLite, but from a different version - check that the DLLs you are using to access it are the latest version, and that you didn't create it in a later application. If in doubt, it's worth setting up a connection in Visual studio via the Server Explorer pane - if "Connect to Database" doesn't list SqLite then see here: http://stackoverflow.com/questions/19665370/missing-sqlite-data-provider-in-vs-2013[^] Once you have a working connection in VS, you can get a "good" connection string in the Properties Pane.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
My next stupid question is: How should I suppose to set a password for sqlite database? :)) Cause obviously I don't know how..I thought that I just have to set there a password..
-
My next stupid question is: How should I suppose to set a password for sqlite database? :)) Cause obviously I don't know how..I thought that I just have to set there a password..
DPaul1994 wrote:
How should I suppose to set a password for sqlite database?
private static string conn = @"Data Source=aplicatie.db;Pooling=true;FailIfMissing=false;Version=3;Password=example";
What happens if you connect using this to a non-existing file?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)