• trycatchfinally 两个重点


     Try          

       con_brmis = Css2DataAccess.GetConnection(Nothing, "css2")            

    tran_All = con_brmis.BeginTransaction("tran_All")            

    Css2DataAccess.ExecuteNonQuery(tran_All, CommandType.Text, Sql_str)

     '將數據傳輸到供應商管理系統中間數據庫 

      Css2DataAccess.ExecuteNonQuery(tran_All, CommandType.StoredProcedure, "SP_ZDF_Master", aPara_Sub)

          ErrorMsg.Text = Resources.CommonLan.UpdateStockSuc           '如果前面执行失败,则直接跳到catch 模块 ,而不再执行以下的代码

       tran_All.Commit()        

    Catch ex As Exception            

    ErrorMsg.Text = ex.Message + "<br>" + Resources.CommonLan.TryOrAsk           

      tran_All.Rollback()        

    Finally            

      con_brmis.Close()         '无论前面是否报异常,都 将执行此模块的语句 ,保证了资源的回收

      End Try

  • 相关阅读:
    02-MySQL的安装和管理
    01-pymysql模块的安装
    异常处理
    USACO 2015 Feb Censoring
    玄武密码(bzoj4327)(JSOI2012)
    浅谈AC自动机
    Equation
    JOI五子棋
    浅谈Tarjan
    年轮蛋糕JOI2014Final
  • 原文地址:https://www.cnblogs.com/withoutaword/p/2560830.html
Copyright © 2020-2023  润新知