想在调用存储过程中出现异常时,将错误重写,比如我在.net客户端
catch (Exception err)
{
Response.Write(err.ToString());
}
这样找到系统提供的错误,但我想得到这类错误的ID号,我根据这类ID重新定义错误,可以重写更人性化的提示。而不是系统提供的提示
SQL中也发了一贴
http://community.csdn.net/Expert/topic/3720/3720418.xml?temp=.4091303
catch (Exception err)
{
Response.Write(err.ToString());
}
这样找到系统提供的错误,但我想得到这类错误的ID号,我根据这类ID重新定义错误,可以重写更人性化的提示。而不是系统提供的提示
SQL中也发了一贴
http://community.csdn.net/Expert/topic/3720/3720418.xml?temp=.4091303
{
if (sEx.Number == 2627)
throw new ecSolutionException("Insert Failed. Duplicate key.", "EX_UPDATE_001");
else
{
throw sEx;
}
}
catch (Exception err)
{
Response.Write(err.ToString());
}
我试用时出错
捕获或抛弃的类型必须从 System.Exception 派生
catch(SqlException sEx)
{
if (sEx.Number == 2627)
// do something
else
{
// do something
}
}
catch (Exception err)
{
Response.Write(err.ToString());
}
至于系统异常,你要看看能否在SQL语句里捕获了。