title: Wrapping a SQLiteConnection with a custom DBConnection class
body: <p>I'm trying to get started with sqlite + C#. I found out that the SQLite-lib isn't a standard-lib, so I added it per reference. </p>
  
  <p>Since I'm using this class more often, I thought about creating an own class, which takes care of everything. </p>
  
  <p>Right now, this is my DB-class:</p>
  
  <pre><code>class DBConnection
  {
  
      public SQLiteConnection m_dbConnection;
  
      public DBConnection()
      {
          Open();
      }
  
      private void Open()
      {
          m_dbConnection = new SQLiteConnection("Data Source=Diary.sqlite;Version=3;");
          m_dbConnection.Open();
      }
  
      public void Close() 
      {
          m_dbConnection.Close();
      }
  
  } 
  </code></pre>
  
  <p>Now, in another <code>Form</code>, I'm trying to access it:</p>
  
  <pre><code>private void FrmLogin_Load(object sender, EventArgs e)
      {
          DBConnection DBConnection = new DBConnection();
          string sql = "SHOW TABLES";
          SQLiteCommand command = new SQLiteCommand(sql, DBConnection);
          SQLiteDataReader reader = command.ExecuteReader();
          Console.WriteLine(reader);
      }
  </code></pre>
  
  <p>This however ends up in the following error:</p>
  
  <blockquote>
    <p>Error CS1503  Argument 2: cannot convert from 'FFR2.DBConnection' to 'System.Data.SQLite.SQLiteConnection'</p>
  </blockquote>
  
  <p>I tried in my DBConnection-class to inherit the SQLiteConnection with this:</p>
  
  <p><code>class DBConnection : SQLiteConnection</code> but that wasn't right as well. I'd like to have a class, which automatically opens the DB, closes on my call and make commands on demand like shown in the example.</p>
  
  <p>Thanks for any advice</p>