'SQLClient What error numbers are related to SQL Server Connection errors so I can retry

I get the following error with SQLClient, are there more error numbers than Error Number: -1, 53, 2?

Error Number: -1, Level: 20, State: 0, Line: 0; Message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Error Number: 53, Level: 20, State: 0, Line: 0; Message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Error Number: 2, Level: 20, State: 0, Line: 0; Message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)



Solution 1:[1]

Please try following link for details of errors

http://technet.microsoft.com/en-us/library/cc645611(v=sql.105).aspx

The error codes are returned by the db server to the sql client.

Update

Try the latest database events and errors here

https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors

Solution 2:[2]

The rules I use for general classification:

  • Number = -1 OR Class/Level/Severity = 20: "Connection Error"

  • Number = -2: "Command Timeout Error"

I believe the negative values are strictly from the client library (ie. network connection issues); this implies the "duplicate" numbers like 2 and 53 come back from the server itself for half-connections.

Other errors (eg. deadlocks/1205) can be more readily defined by the Number.


As the other answer contains, here is also a link to various references:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 user2864740