zoukankan      html  css  js  c++  java
  • c# SQL事务

    SQL事务执行

     SqlTransaction   sqlTransaction   =   sqlConnection.BeginTransaction();   
             SqlCommand   sqlCommand   =   new   SqlCommand();  
             sqlCommand.Transaction = sqlTransaction;
             sqlTransaction.Commit();  
             try   
              {   
                //   利用sqlcommand进行数据操作   
                  ...   
                //   成功提交   
                sqlTransaction.Commit();   
              }   
              catch(Exception   ex)   
              {   
                  //   出错回滚   
                sqlTransaction.Rollback();   
              }  
               finally   
                  {   
                        cnn.Close();   
                        trans.Dispose();   
                        cnn.Dispose();   
                   }    
    没有什么优雅的代码比空代码的执行效率更高
  • 相关阅读:
    leetcode-344-反转字符串
    leetcode-136-只出现一次的数字
    leetcode-350- 两个数组的交集 II
    leetcode-36-有效的数独
    leetcode-283-移动零
    leetcode-387-字符串中的第一个唯一字符
    leetcode-242-有效的字母异位词
    HDU 2612
    Codeforces 1090B
    Codeforces 1090D
  • 原文地址:https://www.cnblogs.com/skyfreedom/p/4975369.html
Copyright © 2011-2022 走看看