1

我编写了一个 T-SQL 查询,其中包括对有效 EmployeeNo 的测试。如果 EmployeeNo 无效,我会执行以下操作:

RAISERROR(5005, 10, 1, N'Invalid Employee No')
return @@Error

回到VB.Net,我测试了sql异常,发现当Employee No无效时,error.number不是我期望的5005,而是2732。

对此有何解释?

谢谢你。

4

1 回答 1

1

您不能在自己的代码中引发错误 5005。只有数据库引擎可以做到这一点。

错误 2732 是表示您无法引发消息 < 50000的错误

SELECT description FROM sys.sysmessages m WHERE m.error = 2732 AND msglangid = 1033

Error number %ld is invalid. The number must be from %ld through %ld and it cannot be 50000.
于 2010-04-29T17:00:15.357 回答