Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loss Connection Detection in ADO

Status
Not open for further replies.

KiwiGuy

Technical User
Mar 13, 2001
15
0
0
GB
Is there event or something that will detect a loss of connection in ADO, eg you are access a db which the network goes down, ADO has still got a connection state of 1, any ideas???

Cheers

Ben
 
Hello,

You need to dim the connection with events:

Dim WithEvents con As ADODB.Connection

Then there will be a disconnect event that will/should be fired when the connection is disconnected:

Private Sub con_Disconnect(adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)

End Sub
 
That doesn't appear to work - it gets fired if the Connection is explicitly closed, but if the database goes away it doesn't fire.

I am also looking for a solution - at the moment, I poll periodically to check the connection, which is something I'd really like to remove.

Chaz
 
Thanks Guy, yes i agree tried using ado events, but as scorpio said this event is only kicked off if the connection is explicitly closed, sigh!!, i also was thinking along the lines of polling for a connection, but was hoping there was a easier why of handling it

Cheers n beers

Ben


 
ADo itself is pretty poor at dealing with this requirement. However, if you are using SQL Server 7, it may be worth checking out the SQL-DMO ActiveX library. it has a SQLServer object that supports a ConnectionBroken event. I suggest thoroughly checking the documentation on MSDN on this to get it to work properly...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top