How to gracefully handle timeout expired?

Hi, there.

I would like to find out is there a better way to handle System.Data.SqlClient.SqlException: Timeout expired.

I am not looking for performance tunning advice or setting timeout to a higher limit, or running a backgroud thred type of advices.

I want to see how to trap it and bubble it up to the end users, then possiblly retry the call later.
It is a win form app in vs2005.

Thanks!


Answer this question

How to gracefully handle timeout expired?

  • Yulia

    Thank you for your reply.

    Yeah, it will be grateful if you can give me a hit for my reference.

    Also, I am using Microsoft ApplicationBlock DataAccess as my data access layer. I am not sure it returns a universal false/nothing or exception code, I may need to write a wrapper for that. Any suggestion along this line is also welcome! Thanks!


  • Tom Frey

    My usual way of handling this is to trap it in my database layer class and return a False or Nothing for the function results. I also have a property where I can retrieve the last exception. Then, in my front end code, I check for the success/fail and if there is a failure I parse the exeception to determine what to do next. Depending on the situation I usually either present a Retry/Cancel message box or retry automatically a certain number of times, usually noting the status on a status bar control.

    If you want more details on how I code this, let me know. It's really a pretty simple implementation of the standard Try...Catch block.



  • How to gracefully handle timeout expired?