首页 > Web开发 > 详细

1 .net 用事物提交执行存储过程

时间:2017-09-14 18:00:43      阅读:185      评论:0      收藏:0      [点我收藏+]
 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();

            }
        }

 

1 .net 用事物提交执行存储过程

原文:http://www.cnblogs.com/mibing/p/7521573.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!