想在调用存储过程中出现异常时,将错误重写,比如我在.net客户端
catch (Exception err)
{
Response.Write(err.ToString());
               
}
这样找到系统提供的错误,但我想得到这类错误的ID号,我根据这类ID重新定义错误,可以重写更人性化的提示。而不是系统提供的提示
SQL中也发了一贴
http://community.csdn.net/Expert/topic/3720/3720418.xml?temp=.4091303

解决方案 »

  1.   

    catch(SqlException sEx)
    {
    if (sEx.Number == 2627)
    throw new ecSolutionException("Insert Failed. Duplicate key.", "EX_UPDATE_001");
    else
    {

    throw sEx;
    }
    }
    catch (Exception err)
    {
    Response.Write(err.ToString());
                   
    }
      

  2.   

    不明白throw new ecSolutionException("Insert Failed. Duplicate key.", "EX_UPDATE_001");
    我试用时出错
     捕获或抛弃的类型必须从 System.Exception 派生
      

  3.   

    那是我项目的东西,你要去掉。
    catch(SqlException sEx)
    {
    if (sEx.Number == 2627)
    // do something
    else
    {
    // do something
    }
    }
    catch (Exception err)
    {
    Response.Write(err.ToString());
    }
      

  4.   

    在存储过程中,使用 raise 语句可以的嘛定指自己的错误。
    至于系统异常,你要看看能否在SQL语句里捕获了。