using (TransactionScope scope = new TransactionScope()) { //创建事物对象 try { //执行事务操作的相关代码 scope.Complete(); //提交事物 } catch (Exception ex) { throw ex; } //抛出异常 finally { scope.Dispose(); } //回滚事物 }