zoukankan      html  css  js  c++  java
  • 1 .net 用事物提交执行存储过程

     public static void delModelReturn(string performanceId,DateTime? effectiveDate=null)
            {
    
                using (SqlConnection con = GetEditorConnection())
                {
                    con.Open();
                    using (SqlCommand command = con.CreateCommand())
                    {
                        SqlTransaction st = con.BeginTransaction();
                        command.Transaction = st;
                        try
                        {
                            command.CommandText = "delModelReturn";
                            command.CommandType = CommandType.StoredProcedure;
                            command.Parameters.Add(new SqlParameter("@p_PerformanceId", performanceId));
                            if (!effectiveDate.HasValue)
                            {
                                command.Parameters.Add(new SqlParameter("@p_EffectiveDate", DBNull.Value));
                            }
                            else
                            {
                                command.Parameters.Add(new SqlParameter("@p_EffectiveDate",effectiveDate));
                            }
                            command.ExecuteNonQuery();
                            st.Commit();
                        }
                        catch (Exception ex)
                        {
                            st.Rollback();
                            throw new Exception(ex.Message);
                        }
    
    
                    }
                    con.Close();
    
                }
            }
  • 相关阅读:
    java面向对象day01
    找工作——JVM内存管理
    找工作——多线程
    找工作-——网络IO
    找工作--volatile
    找工作——异常处理
    找工作--设计模式
    Sqoop安装
    NIO
    Hadoop源码编译
  • 原文地址:https://www.cnblogs.com/mibing/p/7521573.html
Copyright © 2011-2022 走看看