Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-29
5
Medium Priority
?
374 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:Seejaanilkumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 12443463
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
 

Author Comment

by:Seejaanilkumar
ID: 12450339
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13001988
PAQed with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question