I have the following method inside class DBConnection
. I call the method like this: SQLiteConnection conn = DBConnection.OpenDB();
when I want to o
At least in System.Data.SQLite, you can add "FailIfMissing=True
" to your connection string. SQLiteConnection.Open()
will throw a SQLiteException
if the database file does not exist.
string ConnectString = "Data Source=file.sdb; FailIfMissing=True";
DbConnection db = new SQLiteConnection(ConnectString);
db.Open(); // Fails if file.sdb does not exist
See SQLite Connection String Samples for another example, look for "Disable create database behaviour".