Megosztás a következőn keresztül:


Troubleshooting Exceptions: System.Data.SqlClient.SqlException

A SqlException exception is generated when a warning or error is returned by SQL Server.

Associated Tips

  • Verify that you are connecting with valid credentials.
    Make sure that the credentials you are supplying are valid. For more information, see How to: Access SQL Server Using Predetermined Credentials.

  • Verify that the server name is correct and that the server is running.
    Make sure that you are using the correct server name, and that the server can be reached.

Remarks

This exception is thrown whenever the .NET Framework Data Provider for SQL Server encounters an error generated by the server.

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 may 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, a 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 SQL Server Books Online.

See Also

Tasks

How to: Use the Exception Assistant

How to: Access SQL Server Using Predetermined Credentials

Reference

SqlException