title: Make SQLite connection fail if database is missing? (deleted/moved)
body: <p>I have the following method inside <code>class DBConnection</code>. I call the method like this: <code>SQLiteConnection conn = DBConnection.OpenDB();</code> when I want to open an connection, so that I can execute my queries. I can call a similar method when I want to close the connection.</p>
  
  <p>The method:</p>
  
  <pre><code>public static SQLiteConnection OpenDB()
  {
      try
      {
          //Gets connectionstring from app.config
          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;
      }
  }
  </code></pre>
  
  <p>This all works fine and dandy. The problem is the try-catch though. Let us imagine the following scenario:</p>
  
  <ul>
  <li>The database file has been
  moved/delete.</li>
  </ul>
  
  <p>The exception will never be thrown. Actually, the first catch I stumble upon is when I execute my first query - where it figures that there is no such table(s) and it throws its own exception.
  I was stunned by this weird phenomenon, but I soon found out that SQLite creates a new 
  <strong>empty</strong> database. By empty is mean <strong>no tables</strong>, nothing, just an SQLite database file with the same name as the old database which was supposed to be there.</p>
  
  <p>This is an issue, I want the application to know if there is something wrong (database not found, corrupted, being used by another process etc.) as soon as I try to call <code>SQLiteConnection conn = DBConnection.OpenDB();</code>.</p>
  
  <p>Naturally, I could try call a File.Exists in my method, but that doesn't seem like a proper solution. Any help?</p>