我在 SQL 过程中生成引发错误:
RAISERROR('Already exist',-10,-10)
但我无法在 C# 中使用以下代码捕获它
catch (SqlException ex)
{
bResult = false;
if (ex.Errors[0].Number == -10)
{
CommonTools.vAddToLog("bInsertNewUser", "ManageUsers", ex.Message);
if ((savePoint != null))
savePoint.Rollback();
}
}
如何在 C# 中捕获引发的错误?