In C # Is there a way to get finer granularity with SQL exceptions?
I know that a lot can go wrong, but I want to deal with certain cases differently, and parsing the error message doesn't seem very elegant.
Are the error messages generated by the framework also, or are they specific to db?
For example, if I have a primary key violation in INSERT, the error message will always be:
Violation of PRIMARY KEY "PK_tblProduct" restriction. Cannot insert duplicate key into object 'dbo.tblProduct'.
or is it a specific SQLServer.
Update
It looks like I'm after the error number, any idea where I can get the various error numbers?
The best I can do with a quick google: 18456: login failure 18488: Password complete
source
share