Пример #1
0
 public DataTable ExecuteDataTable(DbCommand cmd, Trans t)
 {
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     DbDataAdapter adapter = DbProviderFactories.GetFactory(_dbProviderName).CreateDataAdapter();
     adapter.SelectCommand = cmd;
     DataTable dataTable = new DataTable();
     adapter.Fill(dataTable);
     this._connection.Close();
     return dataTable;
 }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sql = " update transtest set [name]='jhhhh2' where [id]=1 ";
            string sql2 = " update transtest set [name]='love2' where [id]=2 ";
            using (Trans t = new Trans())
            {
                DbHelper dh = new DbHelper();
                try
                {
                    DbCommand cmd = dh.GetSqlStringCommond(sql);
                    dh.ExecuteNonQuery(cmd, t);

                    cmd = dh.GetSqlStringCommond(sql2);
                    dh.ExecuteNonQuery(cmd, t);
                    throw new Exception("hhhhh");
                    t.Commit();
                }
                catch (Exception ee)
                {
                     t.RollBack();
                    Response.Write(ee.Message);
                }
            }
        }
Пример #3
0
 public object ExecuteScalar(DbCommand cmd, Trans t)
 {
     cmd.Connection.Close();
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     object ret = cmd.ExecuteScalar();
     return ret;
 }
Пример #4
0
 public DbDataReader ExecuteReader(DbCommand cmd, Trans t)
 {
     cmd.Connection.Close();
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     DbDataReader reader = cmd.ExecuteReader();
     DataTable dt = new DataTable();
     return reader;
 }
Пример #5
0
 public int ExecuteNonQuery(DbCommand cmd, Trans t)
 {
     cmd.Connection.Close();
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     int ret = cmd.ExecuteNonQuery();
     return ret;
 }
Пример #6
0
 public DataTable ExecuteDataTable(DbCommand cmd, Trans t)
 {
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     DbProviderFactory dbfactory = DbProviderFactories.GetFactory(DbHelper.dbProviderName);
     DbDataAdapter dbDataAdapter = dbfactory.CreateDataAdapter();
     dbDataAdapter.SelectCommand = cmd;
     DataTable dataTable = new DataTable();
     dbDataAdapter.Fill(dataTable);
     return dataTable;
 }
Пример #7
0
 public int ExecuteSql(DbCommand cmd, Trans t)
 {
     cmd.Connection.Close();
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     int num = cmd.ExecuteNonQuery();
     this._connection.Close();
     return num;
 }
Пример #8
0
 public object ExecuteScalar(DbCommand cmd, Trans t)
 {
     cmd.Connection.Close();
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     object obj2 = cmd.ExecuteScalar();
     this._connection.Close();
     return obj2;
 }