0

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

1 Answer 1

1

Have you tried having a look here: How to catch SQLServer timeout exceptions ?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.