How to detect Connection to Db is disconnected

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

How to detect Connection to Db is disconnected

Post by mfauzim » Tue Jan 09, 2007 10:07 am

I managed to setup connection to mssql db thru odbc and able to select and update. The script is running under xp and in vmware.
My issues is sometime the db connection id disconnected. and win will display some dialog box.

My question is, how do I determine whether the db connection is still active or not before issues any exec command in vbscript. Any help is welcome.

regards

User avatar
JRL
Automation Wizard
Posts: 3505
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jan 09, 2007 4:06 pm

Since an error window pops up, can you use OnEvent> to run a subroutine that will accommodate the disconnect? Something like:

OnEvent>WINDOW_OPEN,Error*,1,Reconnect

SRT>Reconnect
CloseWindow>Error*
//whatever code is needed to re-establish the connection
END>Reconnect

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Jan 09, 2007 4:49 pm

if your database connection is somewhat unreliable, you should just include a line or two of VBScript to ensure the connection exists before you try an operation on the database. More than likely, you are getting the "pop up" because you are trying to move the cursor, Read a record, etc...to a closed connection.

could you post a little of your VBScript? It might help us find the problem.

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

It can happen anywhere

Post by mfauzim » Wed Jan 10, 2007 7:58 am

It can happen in any part of the script which try to execute sql. Sometimes it run for days without disconnection. Ilike your idea of checking is connection is up or down. How do you this in vbscript?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts