[dba-VB] Close DB Connection

ACTEBS actebs at actebs.com.au
Tue Nov 30 21:53:10 CST 2010


Hi John,

Would you please give me an example of how you use the destructor class to
close an open db connection? I've researched it, but can't conceptualise how
you'd set it up.

Many thanks...

Vlad

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, 1 December 2010 12:47 AM
To: Discussion concerning Visual Basic and related programming issues.
Subject: Re: [dba-VB] Close DB Connection

I had a similar issue with connections to SQL Server.  When I was
investigating the problem I 
discovered that (in my case) the issue was that the garbage collector (GC)
was taking its sweet time 
collecting the trash, and the connections were not released until the trash
was taken out.

Understand that in my case I was creating classes which created a
collection, then I would destroy 
the class.  Since the GC does its thing whenever it decides that it needs to
free up memory, and 
since I had a lot of memory, the GC decided to take its sweet time.

Once I discovered destructors and dispose, my problems went away.

John W. Colby
www.ColbyConsulting.com

On 11/30/2010 8:06 AM, ACTEBS wrote:
> Hi Everyone,
>
>
>
> I've got this issue with my app where the app keeps it's connection to the
> Access DB open even after the application has finished it's task. I can't
> figure out for the life of me where I've missed closing it in the various
> Functions and Sub Routines.
>
>
>
> I've ensured that cn.Close and cn = Nothing, has been included in all the
> code where the DB is opened. The only place I can't include cn = Nothing
is
> when the connection is encapsulated within a Using Statement where for
some
> reason this is not allowed. Could this be the problem? If so, how can I
> release the connection?
>
>
>
> Also, is there any way of finding out which bit of code is keeping the
> connection open?
>
>
>
> Many Thanks
>
>
>
> Vlad
>
>
>
>
>
>
>
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
>
>
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com











More information about the dba-VB mailing list