日期:2014-05-17  浏览次数:20736 次

产生异常后更新执行成功?

//ExecSql方法
try
            {
                SqlConn.Close(); //sqlconn是创建的一个连接
                SqlConn.Open();
                SqlCommand MyCommand = new SqlCommand(s_Sql, SqlConn);
                if (cmdParms != null)
                {
                    foreach (SqlParameter parm in cmdParms)
                    {
                        MyCommand.Parameters.Add(parm);
                    }
                }
                MyCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw (new ApplicationException(ex.Message));      
            }
            finally
            {
                SqlConn.Close();
            }

//调用的一个更新
try
            {
              IniClass.ExecSql(" UPDATE t1 SET nl=1200 WHERE id=@id ",new SqlParameter("ID", t_id.Text.Trim));
                    
                    MessageBox.Show("修改成功!", "提 示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();  
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提 示", MessageBoxButtons.OK,