Ejemplo 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;
     }
 }
Ejemplo 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;
     }
 }
Ejemplo 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;
     }
 }
Ejemplo 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;
     }
 }
Ejemplo 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;
            }
        }
Ejemplo n.º 6
0
 private void InitSession(DbProvider dbProvider)
 {
     this.dbProvider = dbProvider;
     this.dbProvider.SetEventHandler(Decrypt);
     this.dbTrans = new DbTrans(dbProvider, false);
 }
Ejemplo n.º 7
0
 internal DbBatch(DbProvider dbProvider, DbTrans dbTran)
 {
     this.dbProvider = dbProvider;
     this.dbTrans    = dbTran;
     this.useBatch   = false;
 }