How to check whether database connection is dropped?
Posted on 2004-04-05
I am using adodb (to connect my program with SQL server DB )as follows
Public ConnectDatabase As New ADODB.Connection
Public Sub ConnectCurrent()
Dim ConnectionString As String
On Error GoTo errdesc
ConnectionString = "uid=sa;pwd=;dsn=NPIL"
ConnectDatabase.CursorLocation = adUseClient
MsgBox Err.Description, vbInformation, "Information"
If ConnectDatabase.State = 1 Then ConnectDatabase.Close
While running my program NT/Database connection may break, so I would like to test where database connection is dropped or not. If dropped then again connect it.
I have tried as follows
If ConnectDatabase.State = 1 Then
But after successful connection it alwas shows 1,though it has been disconnected from database.
How to do that one, can any one help me…