Thursday, July 23, 2015

SqlException error numbers for deadlock, connection and command timeouts

I'm posting this here so that I can find it in the future.

When accessing SQL Server via SqlClient (could be ADO.net or Entity Framework), any error is wrapped in an instance of SqlException and the Number property will be set to provide an indication of the specific error condition. In the event of a connection timeout, the Number property will be set to either 2 or 53. A command timeout will set the Number property to -2. And a deadlock will return 1205 in the Number property.

No comments:

Post a Comment