Answer the question
In order to leave comments, you need to log in
How in C# can you determine at the connection stage (before select) whether this is a sqlite3 database or some other file?
I'm connecting to an arbitrary file. I thought an exception would be thrown at the .Open level, but no, as if everything is fine.
SQLiteConnection dbConn = new SQLiteConnection("Data Source=" + dbPath + ";Version=3;Password=" + Pass + ";");
SQLiteCommand sqlCmd = new SQLiteCommand();
dbConn.Open();
sqlCmd.Connection = dbConn;
string sqlQuery = "...................";
SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlQuery, dbConn);
DataTab.Clear();
adapter.Fill(DataTab); //Тут вылетает исключение
Answer the question
In order to leave comments, you need to log in
1 - according to your idea, you will have to open the file, check the signature (see cicatrix's answer), close it if successful
. if there are problems with access, there will still be exceptions, but is it the knowledge of whether this is a base? don't you get
me to the fact that the volume of ancillary work will grow, and more than it was worth
it can still just handle exceptions? As far as I remember .. access rights exceptions are quite recognized. I think the library exceptions for sqlite3 are also quite sane
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question