asp.net.ph

SqlError Class

System.Data.SqlClient Namespace


Collects information relevant to a warning or error returned by SQL Server.

SqlError Class Members

Collapse   Properties

Visibility Name Value Type Accessibility
public Class Byte [ Get ]
public LineNumber Int32 [ Get ]
public Message String [ Get ]
public Number Int32 [ Get ]
public Procedure String [ Get ]
public Server String [ Get ]
public Source String [ Get ]
public State Byte [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public ToString ( ) String

Remarks

This class is created by the SQL Server™ .NET Data Provider when an error occurs. An instance of SqlError is created and managed by the SqlErrorCollection, which in turn is created by the SqlException class.

Messages with 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 usually closes the SqlConnection. However, the user can reopen the connection and continue. In both cases, an SqlException is generated by the method executing the command.

For information on the warning and informational messages sent by SQL Server™, see the Troubleshooting section of the SQL Server™ documentation.

Example

The following example displays each SqlError within the SqlErrorCollection.

public void DisplaySqlErrors ( SqlException myException ) {

   for ( int i=0; i < myException.Errors.Count; i++ ) {
      Response.Write ( "Index #" + i + "<br>" +
         "Error: " + myException.Errors [ ].ToString ( ) + "<br>" );
   }
}
  C# VB

See Also

SqlErrorCollection   SqlException Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph