Reputation: 1774
I set an encryption key for my database in DB Browser for SQLite and now I cannot access it in C#.
Here's the relevant code:
private SQLiteConnection connection;
public DbManager()
{
connection = new SQLiteConnection("Data Source=DB\\gamedb.encrypted.sqlite;Password=p4ssw0rd;Version=3;");
connection.Open();
}
The SQLiteCommand
below throws an exception: "file is encrypted or is not a database".
public Dictionary<string, string> ReadMaps()
{
SQLiteDataReader reader = new SQLiteCommand("select * from Map", connection).ExecuteReader();
Dictionary<string, string> res = new Dictionary<string, string>();
while (reader.Read())
res[(string)reader["Name"]] = (string)reader["Data"];
return res;
}
Is the key specified in the DB browser a different thing than a password?
Upvotes: 1
Views: 1205
Reputation: 1774
I decided to handle setting the password by coding, it works. I created a new project for setting/clearing the password.
Here's the code:
SQLiteConnection conn;
// (code omitted)
private void setPwButton_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(passwordTextBox.Text))
conn.ChangePassword(passwordTextBox.Text);
else
MessageBox.Show("Please specify a password!");
}
private void clearPwButton_Click(object sender, EventArgs e)
{
conn.ChangePassword(String.Empty);
}
Upvotes: 1