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.
[Serializable]
public class SqlException : Exception
{
public SqlException(string message);
public override string Message { get; }
}
SqlException classSqlException(string message)
Message
SqlException when methods such as ExecuteQuery(), ExecuteStatement(), or SQL transaction operations are called after the SQL connection has already been closed.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.