Is it possible that SqlException will be thrown when trying to execute sql procedure and property Number will be 0?
Specific situation: domain controller is not available/not responding and no real communication with sql server occurred.
No, it should not be possible that SqlException.Number is 0, except for the following cases:
Assuming you're not using read-only routing of SQL Server 2016, then none of these cases could apply to the scenario you described.
Remaining cases are either a non-zero number from sysmessages, or a Win32 error code (which, since 0 == ERROR_SUCCESS, would also never be zero).
In practice you will see something along the lines of "Cannot create SSPI context", or "A transport-level error has occurred when sending the request to the server", or a "An existing connection was forcibly closed by the remote host", and those have nonzero Win32 error codes too.
Reference: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlerror.number(v=vs.110).aspx
It may be worth noting that SqlException.Number is synonym for the Number property of the first entry in its Errors array, and that array might contain more than one item.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With