标签:tran user row com use 异常 color aaa 不显示
using (TransactionScope ts = new TransactionScope()) { Model.user_login_log model = new Model.user_login_log(); model.user_id = 0; model.user_name=""; model.remark = Guid.NewGuid().ToString(); model.login_time=DateTime.Now; model.login_ip=Request.UserHostAddress; new BLL.user_login_log().Add(model); model.user_id = 1; new BLL.user_login_log().Add(model); // throw new Exception("aaaaaaaaaaaaaaaa"); //在 ts.Complete();抛出异常,事物会自动回滚 // ts.Complete(); //显示提交事物,如果不显示提交,则事物相当于自动回滚,此代码不可少 // throw new Exception("bbbbbb"); 提交事物后抛出异常,不会影响事物 Response.Write("ok"); }
标签:tran user row com use 异常 color aaa 不显示
原文地址:http://www.cnblogs.com/tiancai/p/6634795.html