.NET 5.0 | Implement SqlException.SqlState
- Dominant language
- C#
- Stars
- 989
- Forks
- 340
- Avg merge
- 4d 18h
- Merged PRs (30d)
- 69
Description
https://github.com/dotnet/runtime/issues/35601 introduces DbException.SqlState for .NET 5.0, for standard 5-character error codes.
SQL Server has its own incompatible [numeric error code scheme](https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors?view=sql-server-ver15), currently surfaced via [SqlError.Number](https://docs.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient.sqlerror.number?view=sqlclient-dotnet-core-1.1#Microsoft_Data_SqlClient_SqlError_Number). However, the SQL Server ODBC driver [apparently maps](https://docs.microsoft.com/en-us/sql/relational-databases/native-client-odbc-error-messages/sqlstate-odbc-error-codes?view=sql-server-ver15) the native SQL Server errors to SQLSTATE values. As pointed out by @cheenamalhotra, the JDBC driver [does the same](https://github.com/microsoft/mssql-jdbc/blob/9c5cc97f661fe14de11df6be16c8acbc3379d1ff/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java#L326), although it maps only a handful of codes (maybe the ODBC translation could be copied?)
Contributor guide
Assessment
This issue has not been assessed yet.