交易范围和正常交易有什么区别? [英] what is the difference between transaction scope and normal transaction ?

查看:70
本文介绍了交易范围和正常交易有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
            {
}

















and

using (IDbTransaction tran = conn.BeginTransaction())
   {
       try
       {
           // transactional code...
           using (SqlCommand cmd = conn.CreateCommand())
           {
               cmd.CommandText = "INSERT INTO Data(Code) VALUES('A-100');";
               cmd.Transaction = tran as SqlTransaction;
               cmd.ExecuteNonQuery();
           }
           tran.Commit();
       }
       catch(Exception ex)
       {
           tran.Rollback();
           throw;
       }
   }









hat是上述两个





hat is the difference between the above two

推荐答案

这篇关于交易范围和正常交易有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆