0

Possible Duplicate:
How to reuse code that reopens connection?

I have a .NET application that makes frequent updates to a database. Sometimes, the database is restarted without any prior notification. In that case the application stops working because of an exception being thrown.

I have to devise a method to make it auto-recover from a lost connection. For that I have written code like this:

while(true)
{
    try
    {
        //Query
        break;
    }
    catch (Exception objException)
    {
        if (!objException.Message.Contains("A transport-level error"))
        {
            throw;
        }
    }
}

Do you think it is effective way to auto-recover?

Community
  • 1
  • 1
harrisunderwork
  • 370
  • 1
  • 6
  • 14

0 Answers0