My Blog is my notepad, I want to mark my work anytime, also i can share my harvest with everyone....

Teracy 's space--->

I love BS Develop ,So i am busying as a bee.Do more,Know more,you will get more.....

博客园 首页 新随笔 联系 订阅 管理
最近在开发过程中用到比较多的批处理让我感觉ADO.NET2.0的事务真的是方便,记得以前的都是:
SqlTransaction trans;

trans = con.BeginTransaction();
cmd.Transaction = trans;
try
{
    cmd.ExecuteNonQuery();
    trans.Commit();
}
catch(Exception e)
{
    trans.Rollback();
}
finally
{
    con.Close();
}
一大堆东西麻烦,看看MSDN中ADO.NET2.0里面的事务:
标准的事务测试方法
这样做的好处就是事务的好处,避免做了第一步数据操作而第二步或者第三不没有做造成数据的不统一。
最后提醒下:要添加引用并using System.Transactions;
posted on 2007-10-12 09:19  Teracy  阅读(575)  评论(3编辑  收藏  举报
One Two Three 向“前”走............
frontpage tracking
Sony Style Coupons