如何使用 c# 代码识别从 sql 存储过程引发的自定义错误消息?
存储过程会像这样引发错误
RAISERROR (N'This is message %s %d.', -- Message text.
10, -- Severity,
1, -- State,
N'number', -- First argument.
5); -- Second argument.
从上面,如何识别错误是自定义错误消息。(即)像这样的东西
try{
--actual code here
}
catch(SqlException ex)
{
--how to check here that the exception is custom one
}