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?