The C# SqlException Class

SqlException is the lightweight managed exception type used by the C# SQL wrapper to report SQL-connection state errors, most notably attempts to execute SQL operations after a SQL connection has already been closed.

For an overview see page SQL Classes

Class Definition

    [Serializable]
    public class SqlException : Exception
    {
        public SqlException(string message);
        public override string Message { get; }
    }

Member Descriptions

SqlException class
Managed exception used by the C# SQL wrapper for SQL-specific runtime checks that do not expose native error-code information.
SqlException(string message)
Creates an SQL wrapper exception with the specified message text.
Message
Returns the exception message supplied by the wrapper.
Typical Trigger
The built-in SQL connection classes throw SqlException when methods such as ExecuteQuery(), ExecuteStatement(), or SQL transaction operations are called after the SQL connection has already been closed.
Typical Usage
Catch SqlException when application code needs to distinguish SQL-wrapper state errors from broader database errors. For native runtime error codes and extended diagnostics, see DatabaseError.
Related Classes
See ISqlConnection, SqlLocalConnection, SqlRemoteConnection, and SqlAggregator for the connection classes that may throw this exception.