Handling Database connection error

H

Harish

Hi All

I have a trouble here to handle database connection error.
Basically I have a program which runs 24 hours and 7 days a week
continuously. In this program I connect to the database and retrieve the data
after every 15 minutes. But sometime there is database connection error and
which stops the program forever. Because it open the database window and ask
to select the datasource, until someone click OK, program doesn’t start. I
have used error handling function but it doesn’t stop to open that database
window.

Here is the Code:

Option Explicit

Sub Macro2()

Code

On Error GoTo Stoprogram
With Selection.QueryTable
.Connection = ODBC;DSN=ABCD;UID=user;PWD=password;SERVER=xyz;"
On Error GoTo Stoprogram
.Refresh BackgroundQuery:=False
End With

Code

Stoprogram:
End Sub


Your help would be greatly appreciated.
Thanks
Harish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top