I'm working some with a database and catching exceptions to check for various conditions. I can't simply catch the sqlException, since it can mean a lot of things, and usually use
catch (SqlException e)
{
if (e.Errors[0].Class == 14)
{
return 0;
}
else ........
To check for specific cases. In this example, class 14 (at least as far as I can tell) signifies a duplicate entry. A different class means the server can't be found, or refusing the connection, or login error, etc. Does anyone know where a list of these error classes could be found? Googling this is difficult since anything with "class" in it turns up the obvious.
A severity of 14 can mean a lot of things:
SELECT message_id, [text]
FROM sys.messages
WHERE language_id = 1033
AND severity = 14;
To see the full list:
SELECT message_id, severity, [text]
FROM sys.messages
WHERE language_id = 1033
AND severity > 0
ORDER BY severity;
I suspect you are more interested in the message_id column than the severity column, as that is a little more specific.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With