Example #1
0
 /// <summary>
 /// 执行sql或者存储过程返回一个object对象+事务
 /// </summary>
 /// <param name="cmd">cmd对象</param>
 /// <param name="t">事务执行操作</param>
 /// <returns></returns>
 public object ExecuteScalar(OleDbCommand cmd, AccessTrans t)
 {
     cmd.Connection.Close();
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     object ret = cmd.ExecuteScalar();
     return ret;
 }
Example #2
0
 /// <summary>
 /// 执行sql或者存储过程返回一个DbDataReader对象+事务
 /// </summary>
 /// <param name="cmd">cmd对象</param>
 /// <param name="t">事务执行操作</param>
 /// <returns></returns>
 public OleDbDataReader ExecuteReader(OleDbCommand cmd, AccessTrans t)
 {
     cmd.Connection.Close();
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     OleDbDataReader reader = cmd.ExecuteReader();
     DataTable dt = new DataTable();
     return reader;
 }
Example #3
0
 /// <summary>
 /// 执行sql或者存储过程返回一个DataTable对象+事务
 /// </summary>
 /// <param name="cmd">cmd对象</param>
 /// <param name="t">事务执行操作</param>
 /// <returns></returns>
 public DataTable ExecuteDataTable(OleDbCommand cmd, AccessTrans t)
 {
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
        OleDbDataAdapter dbDataAdapter =new OleDbDataAdapter();// dbfactory.CreateDataAdapter();
     dbDataAdapter.SelectCommand = cmd;
     DataTable dataTable = new DataTable();
     dbDataAdapter.Fill(dataTable);
     return dataTable;
 }
Example #4
0
 /// <summary>
 /// 执行一条sql语句或者存储过程,返回受影响的行数+事务
 /// </summary>
 /// <param name="cmd">cmd对象</param>
 /// <param name="t">事务执行操作</param>
 /// <returns></returns>
 public int ExecuteNonQuery(OleDbCommand cmd, AccessTrans t)
 {
     cmd.Connection.Close();
     cmd.Connection = t.DbConnection;
     cmd.Transaction = t.DbTrans;
     int ret = cmd.ExecuteNonQuery();
     return ret;
 }
Example #5
0
        /// <summary>
        /// 执行sql或者存储过程返回一个dataSet对象+事务
        /// </summary>
        /// <param name="cmd">cmd对象</param>
        /// <param name="t">事务执行操作</param>
        /// <returns></returns>
        public DataSet ExecuteDataSet(OleDbCommand cmd, AccessTrans t)
        {
            cmd.Connection = t.DbConnection;
            cmd.Transaction = t.DbTrans;

            OleDbDataAdapter dbDataAdapter = new OleDbDataAdapter();
            dbDataAdapter.SelectCommand = cmd;
            DataSet ds = new DataSet();
            dbDataAdapter.Fill(ds);
            return ds;
        }