Esempio n. 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;
 }
Esempio n. 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);
                }
            }
        }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }