Saturday, December 5, 2009

ADO.NET: Exception Handling

From MSDN entry on System.Data.SqlClient.SqlException:

"Messages that have a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement.

The SqlConnection remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the SqlConnection. However, the user can reopen the connection and continue. In both cases, a SqlException is generated by the method executing the command."

The SqlException itself extends DbException. It contains a collection, Error, of type SqlError.

There are parallel exception classes for OleDb, OracleClient, and Odbc. However, these exception classes did not have the same level of detail and specific behavior as that of the SqlException class.

No comments:

Post a Comment