I am using ado 2.8 version. I tried for opening a connection object in synchronous and asynchronous mode. In asynchronus mode it takes 1.5 minutes for returning an error when network failure. For avoiding this I tried in asynchronous mode. Now the contol is coming to the next line, but when I tried to cancel it, it also taking that much time. In effect I can't see any change in time delay when there is no connectivity. I want to cancel/close the connection after 30 seconds and control should be in the very next line. How can I do it?
The code I used is given below
dim gc_connection as new adodb.connection
gs_connect_data = "dsn=esme_linux;UID=cdr;pwd=cdr"
gc_connection.Provider = "MSDASQL"
gc_connection.ConnectionString = gs_connect_data
gc_connection.ConnectionTimeout = 30
c = Now
gc_connection.Open , , , adAsyncConnect
c = Now
Do While True
If DateDiff("s", c, Now) > 30 then
If CBool(gc_connection.State And adStateConnecting) Then
'Comes here only after 1.5 minute if there is no connectivity
MsgBox "open canceled." & c & "," & Now
MsgBox "connection success." & c & "," & Now
ElseIf gc_connection.State <> 1 Then
Set gc_connection = Nothing