Exemplo n.º 1
0
 public int ExecuteNonQuery(DbCommand cmd, DbTrans t)
 {
     cmd.Connection = t.Connection;
     if (t.Transaction != null)
     {
         cmd.Transaction = t.Transaction;
     }
     try
     {
         int ret = cmd.ExecuteNonQuery();
         return(ret);
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 2
0
 public DbDataReader ExecuteReader(DbCommand cmd, DbTrans t)
 {
     cmd.Connection = t.Connection;
     if (t.Transaction != null)
     {
         cmd.Transaction = t.Transaction;
     }
     try
     {
         DbDataReader reader = cmd.ExecuteReader();
         return(reader);
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 3
0
 public object ExecuteScalar(DbCommand cmd, DbTrans t)
 {
     cmd.Connection = t.Connection;
     if (t.Transaction != null)
     {
         cmd.Transaction = t.Transaction;
     }
     try
     {
         object ret = cmd.ExecuteScalar();
         if (ret == DBNull.Value)
         {
             ret = null;
         }
         return(ret);
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 4
0
 public DataTable ExecuteDataTable(DbCommand cmd, DbTrans t)
 {
     cmd.Connection = t.Connection;
     if (t.Transaction != null)
     {
         cmd.Transaction = t.Transaction;
     }
     try
     {
         using (DbDataAdapter dbDataAdapter = dbFactory.CreateDataAdapter())
         {
             dbDataAdapter.SelectCommand = cmd;
             DataTable dataTable = new DataTable();
             dbDataAdapter.Fill(dataTable);
             return(dataTable);
         }
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 5
0
        public object ExecuteScalar(DbCommand cmd, DbTrans trans)
        {
            //调整DbCommand;
            PrepareCommand(cmd);

            //写日志
            WriteLog(cmd);

            try
            {
                if (trans.Connection == null && trans.Transaction == null)
                {
                    return(dbHelper.ExecuteScalar(cmd));
                }
                return(dbHelper.ExecuteScalar(cmd, trans));
            }
            catch (Exception ex)
            {
                WriteExceptionLog(ex, cmd);

                throw ex;
            }
        }
Exemplo n.º 6
0
 private void InitSession(DbProvider dbProvider)
 {
     this.dbProvider = dbProvider;
     this.dbProvider.SetEventHandler(Decrypt);
     this.dbTrans = new DbTrans(dbProvider, false);
 }
Exemplo n.º 7
0
 internal DbBatch(DbProvider dbProvider, DbTrans dbTran)
 {
     this.dbProvider = dbProvider;
     this.dbTrans    = dbTran;
     this.useBatch   = false;
 }