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?