ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Handling Database connection error (https://www.excelbanter.com/excel-programming/381261-handling-database-connection-error.html)

harish

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




All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com