Connection open to nonexistent database succeeds! WTF?
I've written the following code for the ADO.NET client for SQLite, and the
odd thing I've noticed is that even when the connection string passed to it
does not refer to a file that exists, the code returns true! Does SQLite
not actually check for a valid connection until you try to perform a data
operation? The result I get when trying to insert a row to a table in a
nonexistent database is "Sql logic error" "table doesn't exist" -- no
kidding, because there's no such database file!
Is this expected behavior?
public bool ConnectionOK(string ConnString)
bool result = true;
if (DbPath.Length > 0)
sqlConnection = new SQLiteConnection(ConnString);
if (sqlConnection.State == ConnectionState.Open)
catch (Exception ex)
result = false;