Hi,
I have a long running process - Windows Service which is using SubSonic 2.2 for database access - in this case, accessing a SQL 2005 database. (I can't move to SubSonic 3, as we can't use .NET 3.5)
This service is polling a database table (amongst other things). I would like to handle the event where it loses the database connection.
We currently do that by crudely doing the following :-
while (1 < 2)
{
try {
MyTable.Load();
foreach(MyRow in MyTable)
{
fireEvent();
}
}
catch (Exception e)
{
logger("Connection failed");
}
Thread.Sleep(1000)
}
This catches the loss of the database connection successfully. I am currently testing this by just merely stopping the SQL Server service and then stepping through the code. When I restart the SQL Service service, I then get a new exception stating the login for the database is incorrect - when it obviously is correct :) It never recovers from this exception.
How can I handle losing the connection? I would really like it to keep trying as it does at the moment and automatically re-establish the connection when it can. Is there some kind of database reset command in SubSonic?