Пример #1
0
 public BuildQuery(string ConnString)
 {
     //Initialize hashtable which is going to hold parameter collections
     m_ParamCollection = new Hashtable();
     //Set Sql connection string 
     ConnectionString = ConnString;
     //Initailize datalayer object
     m_oDbManager = new DataManager(DataManager.DatabaseType.MsSql);
 }
Пример #2
0
 protected object ExecuteQuery(DbConnection DbConn, DbTransaction DbTrans, string spName, CommandType CmdType, Hashtable ParamTable, DataManager.ExecuteAction ExecAction)
 {
     if (this.ValidateCommandText(spName))
     {
         try
         {
             if (DbConn.State != ConnectionState.Open)
             {
                 DbConn.Open();
             }
             DbCommand dbCommand = this.GetDbCommand(spName, DbConn);
             dbCommand.Transaction = DbTrans;
             try
             {
                 dbCommand.CommandType = CmdType;
                 if (ParamTable != null)
                 {
                     Array hashValue = Utils.GetHashValue(ParamTable);
                     for (int index = 0; index < hashValue.Length; ++index)
                     {
                         dbCommand.Parameters.Add((object)(DbParameter)hashValue.GetValue(index));
                     }
                 }
                 if (ExecAction == DataManager.ExecuteAction.NonQuery)
                 {
                     long num = long.Parse(dbCommand.ExecuteNonQuery().ToString());
                     return (object)num;
                 }
                 else
                 {
                     object obj = dbCommand.ExecuteScalar();
                     return obj;
                 }
             }
             catch (Exception ex)
             {
                 throw ex;
             }
             finally
             {
                 if (this.m_CloseConnection)
                 {
                     DbConn.Close();
                     dbCommand.Dispose();
                 }
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             if (this.m_CloseConnection)
             {
                 DbConn.Dispose();
             }
         }
     }
     else
     {
         throw new Exception("Command text empty");
     }
 }
Пример #3
0
 public DataManager(DataManager.DatabaseType bkendType)
 {
     this.BackendType = bkendType;
 }