Does SQL Server 2005 error message numbers back to the asp.net application?
Posted
by Duke
on Stack Overflow
See other posts from Stack Overflow
or by Duke
Published on 2010-06-09T16:12:52Z
Indexed on
2010/06/09
16:22 UTC
Read the original article
Hit count: 234
I'd like to get the message number and severity level information from SQL Server upon execution of an erroneous query.
For example, when a user attempts to delete a row being referenced by another record, and the cascade relationship is "no action", I'd like the application to be able to check for error message 547 ("The DELETE statement conflicted with the REFERENCE constraint...") and return a user friendly and localized message to the user.
When running such a query directly on SQL Server, the following message is printed:
Msg 547, Level 16, State 0, Line 1
<Error message...>
In an Asp.Net app is this information available in an event handler parameter or elsewhere?
Also, I don't suppose anyone knows where I can find a definitive reference of SQL Server message numbers?
© Stack Overflow or respective owner