connection from asp.net to sqlserver2000 remains open and blocks other connections.

A

avnrao

best way is to override dispose on that general class.. and you can call it
explicitly or use using() block.
deconstructor gets called when object is removed (i guess when GC is
collecting the object)..

destructors also be called when program exists. is your program existing
here?
Av.
 
P

Patrice

Do you have a message saying the connection pool is full ?

Remember that finalization in .NET is not deterministic and here I suspect
you still have a reference.

I would close explicitely the DB connection as soon as I'm done with it.

Patrice
 
Z

z. f.

Hi,

i use asp.net and i have a general class that manages database access using
ado.net and sqlclient provider.
this class upon deconstructor closes connection to DB.

it appears on sql 2000 manager when i look in management/current
activity/Process Info that my connections stays open and the number of
connections open is increasing each request.

what am i missing / doing wrong here.
thanks for any input from your experience.

z.
 
Z

z. f.

well, since it's an aspx page, the program is aspnet.exe on win2k or
w3wp.exe on win2003 and this process should stay in memory for long time.
so i need to take care of my objects my self.
thanx.
 
M

M. Zeeshan Mustafa

ADO.NET manages connection pooling itself, If you do a close or dispose
it does'nt really mean that connection to db server is closed. When you call
connection.close or adapter.close, it actually closes connection to your
applications
object with ado.net, on the other hand ADO.NET is itself maintaining
connections
with database.
Its very important to close both data reader and connection as soon as they
are no longer needed. if you do not do this, they will go out of scope and
the
application will leak a connection and u'll see one more connection.

check this msdn documentation for reference:
http://msdn.microsoft.com/library/en-us/vbcon/html/vburfintroductiontoadoconnectiondesigntools.asp
 
W

William \(Bill\) Vaughn

It is not a good idea to let the finalizer (or deconstructor) close
connections--it simply won't work. As others have said, close the
connections explicitly.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top