Re: Connection Pooling with Global ADO.Connection Object
"Eric Litwin" <firstname.lastname@example.org> wrote:
You have to "Open" the connection for the second class. You used it for
the initial class call, then you closed it. So, the next class that is instantiated
and uses your global connection needs to re-OPEN it (it is closed, not set
Use something like this when closing a connection:
If Conn.State =adStateOpen then
When opening it use (put this where global connection is created):
If Conn.State =adStateClosed then
This will work for you. Again, the connection is not set to nothing, it
is just closed, but hangs in there till you re-open it.
>I have an N-Tier framework that attempts to implement connection pooling
>the data layer (if that layer is run on the client).
>I do this by having a public global ADO Connection object in a module within
>the data layer. I initialize the object (New) at start-up, Open and then
>immediately Close the connection. I do not set this object to Nothing until
>the program shuts down. (This object is also used for transaction control
>if the layer is not in MTS.)
>The problem I have is that the when I run my project group with all the
>in the VB6 IDE, the global connection object remains initialized and works
>properly. However, when I compile the Data Access layer, the object gets
>initialized (New->Open->Close) properly and I can use it once from one of
>the Classes. When another class tries to access the connection object,
>has been set to nothing and I am forced to set it to New again before I
>to Open it.
>I am pretty sure I am losing the connection pooling once the object is set
>to nothing. I cannot figure out where/why it is getting set to nothing.
>I only explicitly set it to nothing on shutdown. My class modules use Command
>objects and recordsets that set their "ActiveConnection" property to this
>connection object, and when they are finished, they Close the Recordset/Command
>object and set it to nothing. I put traces in the code at these points
>the Global connection object is still around. It just disappears the second
>time I try to access it when a new Class module is created.
>Any help/ideas would be greatly appreciated.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL