开发者

sql raiseerror error.number wrong in VB

开发者 https://www.devze.com 2022-12-28 10:18 出处:网络
I wrote a T-SQL query which includes a test for valid EmployeeNo. If the EmployeeNo is not valid, I do the following:

I wrote a T-SQL query which includes a test for valid EmployeeNo. If the EmployeeNo is not valid, I do the following:

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

Back in VB.Net I test the sql exception and found that when the Employee No is invalid 开发者_如何学Pythonthe error.number is not 5005 as I would expect, but 2732.

What is the explanation for this?

Thank you.


You can't raise an error 5005 in your own code. Only the DB Engine can do this.

Error 2732 is the error that says you can't raise messages < 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.
0

精彩评论

暂无评论...
验证码 换一张
取 消