tags:

views:

13

answers:

1

Hi, How do get the specific exception that has caused a sql server command to happen using the SqlException object that I have caught. I want to know when a Command timeout has occured, i.e.

try { // database ExecReader call } catch (SqlException sqlEx) { // what can I test here to find if this is a command timeout exception }

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

Can I test sqlEx.Number or sqlEx.ErrorCode for the command timeout. Is there a list of codes (for sqlEx.Number) and there corresponding meanings, I have googled but can't seem to find one and do the codes change depending on the version of sql server that I am using?

Thanks for any help, Nick

A: 

Have you tried having a look here: http://stackoverflow.com/questions/29664/how-to-catch-sqlserver-timeout-exceptions ?

openshac