Manage exceptions when selecting, modifying data
The SqlException
has a Number property that you can check.
The following table describes the possible values for this property:
Source of Error
SqlError.Number
SqlException has inner Win32Exception (beginning with.NET Framework 4.5)
Error from server
Server error code
This number corresponds to an entry in the master.dbo.sysmessages
table.
No
Connection timeout
-2
Yes (Number = 258)
Communication error (non-LocalDB)
Win32 error code
Yes (Number = Win32 error code)
Communication error (LocalDB)
Win32 error code
No
Encryption capability mismatch
20
No
Failed to start LocalDB
Win32 error code
No
Read-only routing failure / Server had severe error processing query
0
No
PreviousHandle and diagnose database connection exceptionsNextBuild command objects and query data from data sources
Last updated