public void update(string str,string No)
        {
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["con"]);
            try
            {
               
                con.Open();
                string sql = "update B_AttachmentType set Ratio='" + str + "' where AttachmentTypeID='" + No + "'";                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.ExecuteNonQuery();
            }
            catch (Exception x)
            {
                throw (x);
            }
            
        }
如以上代码,加入了try catch ,但是遇到错误时页面还是报错,怎样是页面不报错,继续执行
catch里面怎样写代码?

解决方案 »

  1.   

    throw (x);
    注释掉就不报错了
      

  2.   

    是不是 throw (x); 出去的异常被页面捕获了。
    把 throw (x);去掉试下
      

  3.   

    "update B_AttachmentType set Ratio='" + str + "' where AttachmentTypeID='" + No + "'";sql语句在sql server上试下看下有问题吗
      

  4.   

    throw (x);
    改成
    Response.Write(x);
      

  5.   

    throw new Exception("错误了"+e.ToString())
    试试这个行不行
      

  6.   

    加个Label也行啊
    Label1.Text = x.Message;
      

  7.   

     throw (x);
      你抛出异常了。
      

  8.   

    throw (x);
    你又把异常抛出来了
      

  9.   

       catch (Exception ex)
                {
                    throw new DAOException(string.Format("修改信息时失败!"),ex);
                }
      

  10.   

    catch(Exception err)
    {
        lable1.text=err.message;///此处对错误信息任意处理,没throw就不出现大黄页了
    }