attempt reconnect on connection failure

Joined
Oct 5, 2010
Messages
1
Reaction score
0
hi ..

Hoping someone may be able to help me with a database adp front end / sql backend... overnight (during backup, i think) it suffers a loss of connection. I then get the classic runtime error or connection failure modal dialog and I have ot restart the app..

What I would like to do is simply supress/hide the error and attempt a reconnect at every 2 mins.. I have a hidden form that in it's Ondisconnect event I have set the TimerInterval to 12000 in the Onconnect I set it back to 0 and in the OnTimer event I have the following connection code to reconnect..

.. Will this work? If so how may I supress the error dialog..

many thanks..

Private Sub Form_OnConnect()

Set TimerInterval = 0

End Sub

Private Sub Form_OnDisconnect()
On Error GoTo proc_error
With CurrentProject
If Not .IsConnected Then

Call LetConnectionString

End With

ExitProc:
Exit Sub
ProcError:
Set TimerInterval = 12000
Resume ExitProc

End Sub

Private Sub Form_Timer()

Call LetConnectionString

End Sub

Public Sub LetConnectionString()
With CurrentProject
If Not .IsConnected Then
.OpenConnection ("PROVIDER=SQLOLEDB.1;" _
& "INTEGRATED SECURITY=SSPI;" _
& "PERSIST SECURITY INFO=FALSE;" _
& "INITIAL CATALOG=DbName;" _
& "DATA SOURCE=SERVER;" _
& "Use Procedure for Prepare=1;" _
& "Auto Translate=True")
End If
End With
End Sub
 
Last edited:
Back
Top