Ok, since you agreed with this, I'll extend the comment with some code here. This is how I imagined the stuff there.
static void connectToDB()
{
throw new Exception("DB is down");
}
static void Main(string[] args)
{
bool connected = false;
while (!connected)
{
try
{
connectToDB();
connected = true;
}
catch (Exception ex)
{
System.Threading.Thread.Sleep(1000);
}
}
}
See if it helps; if not, we might need some more information.