首页 > 其他 > 详细

C# 事务处理

时间:2014-06-18 17:58:13      阅读:389      评论:0      收藏:0      [点我收藏+]
       /// <summary>
        /// 发送消息;  先插入“发件箱”表;而后插入“收件箱”(批量发送选定用户)表;
        /// </summary>
        /// <param name="parms"></param>
        /// <param name="isSend"></param>
        /// <param name="messageId"></param>
        /// <param name="allId"></param>
        /// <returns></returns>
        public static int InsertMessageToOutbox(SqlParameter[] parms, bool isSend, string messageId, string allId)
        {
            int result;
            try
            {
                SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringDefault);
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    result = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, "InsertMessageToOutbox", parms);
                    if (isSend)
                    {
                        //DataTable dt=
                        BatchAddInbox(conn, allId, messageId, tran);
                    }
                    else
                    {
                        if (result > 0)
                        {
                            result = 1000;
                        }

                    }
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw new Exception();
                }
            }
            catch
            {
                result = 0;
            }
            return result;
        }

 

C# 事务处理,布布扣,bubuko.com

C# 事务处理

原文:http://www.cnblogs.com/kedarui/p/3790919.html

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