Opening a connection to oracle database using ado takes more time when network failure

Hi,

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
               gc_connection.Cancel
'Comes here only after 1.5 minute if there is no connectivity
               MsgBox "open canceled." & c & "," & Now
               Exit Sub
            Else
               MsgBox "connection success." & c & "," & Now
               Exit Do
            End If
        ElseIf gc_connection.State <> 1 Then
            sleep(1)
        End If
    Loop
    gc_connection.Close
    Set gc_connection = Nothing

Seeja
SeejaanilkumarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Arthur_WoodCommented:
Are you not attempting to connect to an ORACLE database?

This line:

 gc_connection.Provider = "MSDASQL"


specifies that your provider is for SQL Server.

Change it to:

 gc_connection.Provider = "MSDAORA"

and then re-try.


like this:

dim  gc_connection    as new adodb.connection
    gs_connect_data = "dsn=esme_linux;UID=cdr;pwd=cdr"
    gc_connection.Provider = "MSDAORA"
    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
               gc_connection.Cancel
'Comes here only after 1.5 minute if there is no connectivity
               MsgBox "open canceled." & c & "," & Now
               Exit Sub
            Else
               MsgBox "connection success." & c & "," & Now
               Exit Do
            End If
        ElseIf gc_connection.State <> 1 Then
            sleep(1)
        End If
    Loop
    gc_connection.Close
    Set gc_connection = Nothing


AW
0
SeejaanilkumarAuthor Commented:
My database can be oracle, sql server, access or any database which can be connected through a dsn. I am using this provider bcz all the databases can be connetced throgh this provider. If it is MSDAORA, only oracle database connectivity can be established. So my provider must be MSDASQL. The connection timeout is working in other databases such as SQL server etc. But with oracle, my exe will be seemed to be idle in that line (.cancel) in network failure.
0
moduloCommented:
PAQed with points refunded (250)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.