业务逻辑层日志 的操作方法:
1, 添加 引用: System.Transactions;
2, 添加namespace using System.Transactions;
3, using (TransactionScope scope=new TransactionScope())
{
try
{
DataAccess.ExecuteNonQuery("update a set c='frank' where b=1");
if (rlt==true)
{
throw new Exception();
}
scope.Complete();//如果成功,则提交数据库,否则,会自动回滚!!!
Response.Write("success!");
}
catch
{
rlt=false;
}
}
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)