数据库超时异常怎么捕捉 SQL2005 数据库,执行SQL语句时间过长,超过了设定的时间, 系统自动弹出超时错误, 我想捕捉到这个超时的异常,然后提示自定的异常页面,怎么能实现呀?

解决方案 »

  1.   

    try
    {
        //数据库操作
    }
    catch(Exception ex)
    {
       messbox.show(ex.message)
    }
      

  2.   

    try 

        //数据库操作 

    catch(Exception ex) 

      MessageBox.Show(ex.message) 
    }正解你可以把
      

  3.   

    楼主说的是SQL里的吧,追踪一下.
      

  4.   


                try
                {}
                catch(System.Exception ee) 
                {
                   response.redirect("<script language=javascript>alter("+ee.Message.ToString()+")</script>)
                }
      

  5.   


               SqlConnection sql= new SqlConnection (ConfigurationManager .AppSettings ("XXX"));
                SqlCommand CMD=new SqlCommand ("sql语句",sql);
                try
                {
                    sql.Open ();
                    //SQL
                }
                catch(System.Exception ee) 
                {
                   response.redirect("<script language=javascript>alter("+ee.Message.ToString()+")</script>");
                }