Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


ADO adStateOpen and connection timeout

Posted on 1999-07-28
Medium Priority
Last Modified: 2013-12-25
Hi, sometimes my connection (Dim cn as new ADODB.Connection) may timeout. And when the program tries to access the cn again, it will give error "The application requested an operation on an object with a reference to a closed or or invalid connections object".

So I added the following code to detect whether cn is still open or not :

If cn.State <> adStateOpen Then
   cn.ConnectionString = connectionStr
End If

However, I find that it does not work. It still give the a/m error or "not connected to ORACLE".

Is there any other way I can detect if the connection has already timeout so I can make a connection again?

My environment is NT, VB6, Oracle.

Question by:janeb
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
1 Comment

Accepted Solution

AnswerTheMan earned 400 total points
ID: 1507237
first you sould wrote :
                If cn.State <> adStateClose Then
                   cn.ConnectionString = connectionStr
                End If
But even that -  don't count on the adStateClose in this case.
the meaning of the msg you get is that some objects in your application
(Controls probably), which were bound to the DB through the Connection(CN)
were left without it.
you should search your code for such cases. if found - you should set their
DataMember="", so they will lose their connection with CN. later - reconnect them.
now, the same is for Recordsets based on this connection. Closing them is not
enough, and you MUST Set them to NOTHING. otherwize - you face this conflict
of what's looks like a Closed connection, but leaving objects orpaned.


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

661 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