Name

SqlError

Synopsis

This class represents one or more data source errors, but it isn’t an exception. Instead, the data source may report multiple errors, and multiple SqlError instances may be added to a single SqlErrorCollection, which are then accessed using the SqlException.Errors property of the exception that is raised.

SQL Server errors contain information about the command causing the error (Procedure provides the procedure name, and LineNumber indicates which statement failed), the instance of SQL Server where the error occurred (Server), and a descriptive text message (Message). Additional numeric information is provided, such as the error code (State) that can be “translated” using the SQL Server 2000 Books Online, a number that indicates the type of error and maps to an entry in the master.dbo.sysmessages table (Number), and a severity level from 1 to 25 (Class). Messages with a severity level of 10 or less are informational. All errors of level 16 or less are probably generated by the user (for example, invalid input or a miscoded stored procedure) and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. The SqlConnection remains open if the severity level is 19 or less; if the severity level is 20 or greater, the server usually closes the connection. However, you can reopen the connection and attempt to continue. Severity levels of 20 or above are fatal and usually prevent any work from being accomplished with SQL Server. ...

Get ADO.NET in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.