View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
harish harish is offline
external usenet poster
 
Posts: 14
Default Handling Database connection error

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 doesnt start. I
have used error handling function but it doesnt 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