I have the following method inside class DBConnection. I call the method as follows: SQLiteConnection conn = DBConnection.OpenDB();when I want to open a connection so that I can fulfill my requests. I can call a similar method when I want to close the connection.
Method:
public static SQLiteConnection OpenDB()
{
try
{
string myConnectString =
ConfigurationManager.ConnectionStrings[
"LegMedSQLLite.Properties.Settings.LegMedSQLLiteDBConnectionString"].ConnectionString;
var conn = new SQLiteConnection(myConnectString);
conn.Open();
return conn;
}
catch (SQLiteException e)
{
MessageBox.Show(e.ToString(), "TEST");
return null;
}
}
All this works great and dandy. However, the problem is trying to capture. Imagine the following scenario:
- The database file has been moved / deleted.
. , , , - - , (), .
, , SQLite
. , , SQLite , , .
, , , - ( , , ..), SQLiteConnection conn = DBConnection.OpenDB();.
, File.Exists , . ?