C#中的MC Access事务

时间:2016-06-23 21:27:49

标签: c# asp.net ms-access

这可以用于方法的事务吗?我得到了读取/插入/更新ms访问的方法。

using (OleDbConnection conn = new OleDbConnection(ConnectionString)) {

     OleDbCommand cmd = new OleDbCommand();
     cmd.CommandText = "BEGIN TRANSACTION";
     cmd.ExecuteNonQuery();

    //C# code, methods etc where I put some values into db via OleDbCommand etc

     cmd.Parameters.Clear();
     cmd.CommandText = "COMMIT [TRANSACTION | WORK]";
     cmd.ExecuteNonQuery();

     //No idea what to put here.. 

     cmd.Parameters.Clear();
     cmd.CommandText = "ROLLBACK [TRANSACTION | WORK]";
     cmd.ExecuteNonQuery();

}

0 个答案:

没有答案