Re: Why use Connection.Close in ADO?



jeff wrote:
I have an application that runs on a COM+ server and talks with a
Sybase Database. The application does not containe any
connection.close methods.
It uses set connection = nothing in place of close and then a set to
nothing. Now this is an application I am taking over from another
programmer and I am wondering what problems this may cause?

Most of the set connection = nothing is in the terminate methods of
the class.

Setting the connection to nohing is supposed to cause the connection to
close. However, if child objects are open, or if a transaction is
active, the connection may refuse to close, causing an orphaned object,
i.e., a memory leak.

There are two possible consequences of failing to use the Close method:
1. Connections may be left open longer than they need to be, causing new
connections to be spawned by other threads/processes instead of existing
connections being used from the session pool, resulting in too many
connections open to the server at once. This can cause sporadic
connection failures. In a server environment, it is critical that
connections be closed as soon as the code is finished with them to
maximize session pool effectiveness.
2. Setting the connection to nothing (dereferencing it) is supposed to
cause the connection to close. However, if child objects are open, or if
a transaction is active, the connection may refuse to close, causing an
orphaned object, i.e., a memory leak.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • Re: VBA to SQL DB with user input and results to worksheet
    ... Dim InP As String ... Dim Connection As ADODB.Connection ... Set Connection = New ADODB.Connection ...
    (microsoft.public.excel.programming)
  • Re: New Connection Greyed Out
    ... about creating a new dial up connection before even entering Windows. ... "Malke" wrote: ... Option in New Connection Wizard is Unavailable ... I did Google for "cannot set connection to dial up to a domain" and got a few possible links to follow. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Question on SQL from XL to Access
    ... if I want to make multiple queries against the same db. ... close the db connection after every query? ... I tried keeping the connection ... Set Connection = CreateObject ...
    (microsoft.public.excel.programming)
  • Re: How do I build an excel query? (something like SQL)
    ... Dim Connection As ADODB.Connection ... Dim ConnectionString As String ... Set Connection = New ADODB.Connection ...
    (microsoft.public.excel.programming)
  • Re: VBA to SQL DB with user input and results to worksheet
    ... Dim SQL As String ... input data to SQL ... Dim Connection As ADODB.Connection ... Set Connection = New ADODB.Connection ...
    (microsoft.public.excel.programming)