• ADO.NET 1.1和2.0事务的区别


    SqlTransaction trans;

    trans = con.BeginTransaction();
    cmd.Transaction = trans;
    try
    {
        cmd.ExecuteNonQuery();
        trans.Commit();
    }
    catch(Exception e)
    {
        trans.Rollback();
    }
    finally
    {
        con.Close();
    }
    ================================
    using System.Transactions;
    //// <summary>
    /// 事务测试方法-- Add by Teracy on 2007-09-09
    /// </summary>

    void TestTransaction()
    {
     TransactionOptions options = new TransactionOptions();
     options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
    options.Timeout = TransactionManager.DefaultTimeout;

               using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
             {
                  //数据操作第一步;
                //数据操作第二步;
               //数据操作第三步;
                 scope.Complete();        
               }

      }
  • 相关阅读:
    发布自己的包到Nuget上
    asp.net core 中的MD5加密
    asp.net core csrf
    KNN算法
    ios测试apk
    python多进程
    机顶盒 gettimeofday()获取毫秒溢出
    Kiggle:Digit Recognizer
    Kaggle:Titanic: Machine Learning from Disaster
    Python抓取微博评论
  • 原文地址:https://www.cnblogs.com/RobotTech/p/922271.html
Copyright © 2020-2023  润新知