title: C# - A class for Generic database connection, command, reader
body: <p>Suppose I am designing a class that can handle any database technology to create a connection, execute command and retrieve data, etc.</p>
  
  <p>If I need to create a generic database handling class for existing RDBMSs (like SQL Server, Oracle, FireBird, et.), which .net abstract-class/Interface should I use {DbConnection, DbCommand, DbParameter,...} or {IDbConnection, IDbCommand, IDbParameter,...}?</p>
  
  <p>Should I use the code like </p>
  
  <pre><code>public bool CreateConnection(DatabaseTypeEnum type)
  {
      DbConnection conn ;
  
      if(type==DatabaseTye.Oracle)
      {
          //....
      }    
  }
  
  public DbDataReader GetData()
  {
  
      DbCommand comm;
      //...
  }
  </code></pre>
  
  <p>or,</p>
  
  <pre><code>public bool CreateConnection(DatabaseTypeEnum type)
  {
      IDbConnection conn ;
  
      if(type==DatabaseTye.Oracle)
      {
          //....
      } 
  }
  
  public IDbDataReader GetData()
  {
  
      IDbCommand comm;
      //...
  }
  </code></pre>
  
  <p>And, Why?</p>