zoukankan      html  css  js  c++  java
  • asp.net sql事务 枫

     using (SqlConnection connection = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))       

    {

     connection.Open();

    SqlCommand command = connection.CreateCommand();

    SqlTransaction transaction;           

    transaction = connection.BeginTransaction("SampleTransaction");           

    command.Connection = connection;           

    command.Transaction = transaction;

     try           

    {               

    command.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, ''Description'')";                command.ExecuteNonQuery();               

    command.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, ''Description'')";                command.ExecuteNonQuery();                // Attempt to commit the transaction.               

    transaction.Commit();                          

    }           

    catch (Exception ex)           

    {               

    try               

    {                   

    transaction.Rollback();               

    }               

    catch (Exception ex2)               

    {                   

    //Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());                   

    //Console.WriteLine("  Message: {0}", ex2.Message);               

    }           

    }       

    }

  • 相关阅读:
    关于mysql主从架构master宕机
    恢复drop后的表空间
    rman 恢复drop 表空间模拟恢复
    backup controlfile 和create standby controlfile
    catalog
    rman恢复表(不完全恢复)--需要关闭数据库
    rman备份恢复
    oracle DG 启动和关闭顺序
    ASM-本地数据拷贝
    图解Java设计模式之模板模式
  • 原文地址:https://www.cnblogs.com/mrray/p/2049632.html
Copyright © 2011-2022 走看看