public virtual void CloseDb(SqlDb db)
 {
     if (!db.IsClosed)
     {
         if (!db.IsAdapter && db.Connection != null)
         {
             SqlConnection cn = (SqlConnection)db.Connection;
             if (cn.State != ConnectionState.Closed)
             {
                 cn.Close();
             }
             cn.Dispose();
             db.Connection = null;
         }
     }
 }
 public virtual void OpenDb(SqlDb db)
 {
     if (db.IsClosed)
     {
         if (db.Connection == null)
         {
             db.Connection = new SqlConnection(connString);
             db.Connection.Open();
         }
         else
         {
             if (db.Connection.State == ConnectionState.Closed)
             {
                 db.Connection.Open();
             }
         }
     }
 }