I'm trying to catch an SQLite problem but I'm unsure how.
The problem is opening a database which is password protected.
No error appears to be thrown when opening a database with an incorrect or no password.
I tried the following.
SQLiteConnection m_dbConnection = null;
try
{
m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;Password=password");
m_dbConnection.Open();
}
catch(SQLiteException)
{
MessageBox.Show("error");
}
if (m_dbConnection == null)
{
MessageBox.Show(m_dbConnection.ToString());
}
My goal here is to be aware that an incorrect password was entered before proceeding but I'm unsure how, and wondering what the correct procedure is.
In the above code no Message box is displayed, but if I try to query the connection it fails.
I don't believe it wise to hard code a password in.
Thank you for looking.