zoukankan      html  css  js  c++  java
  • 微软企业库回滚操作

                SqlDatabase db = new SqlDatabase(@"server=.\sql2008;uid=sa;pwd=abc@123;database=EFDemo");

                DbConnection dbconn 
    = db.CreateConnection();
                dbconn.Open();
                DbTransaction Idbtran 
    = dbconn.BeginTransaction();
                
    try
                {
                    DbCommand sql 
    = db.GetSqlStringCommand("Insert Into [Author](FirstName,LastName) Values('han1','wei1')");
                    db.ExecuteNonQuery(sql,Idbtran);
                    DbCommand sql1 
    = db.GetSqlStringCommand("Update [Author] Set LastName = 'wei1xiu' where FirstName='han1'");
                    db.ExecuteNonQuery(sql1,Idbtran);

                    Idbtran.Commit();
                }
                
    catch
                {
                    Idbtran.Rollback();
                }
                
    finally
                {
                    dbconn.Close();
                }
                Console.WriteLine(
    "OK");
                Console.ReadKey();
  • 相关阅读:
    [bzoj 2460]线性基+贪心+证明过程
    [Wc2011] Xor
    [BZOJ2844]线性基+xor本质不同第K大
    洛谷3857 [TJOI2008]彩灯
    HDU3949 异或线性基
    hdu3062 party --2-sat
    KM算法详解+模板
    Hopcroft-Karp算法
    bzoj 1135: [POI2009]Lyz
    hall定理的证明
  • 原文地址:https://www.cnblogs.com/hantianwei/p/2027101.html
Copyright © 2011-2022 走看看