Open Database Connections Problem

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

Hey!

I have problems with timeout cause of problems obtaining a pool in the SQL
server.. and I guess It's because I might have forgotten to Close some
sqlConnection somewhere.. so I search thru my project and found 172 places
where I open a connection and I steped thru all the code in those place to
see if there was a Close command for each Connectionobject. In someplaces I
had to add a close command and then I recomplied and updated the Solution.

I still get the same problem.. from a spefiic situation where a few special
pages are involved. that makes me think it is a problem in the code and not
with the server or poolsize or anything. I have looked thru the code again
and there is for sure a Close command for each Open.

In Try statements I have put the Close command in the Finally statement
(that's the way to do it right?)

please help, what else have I missed?

/Lars Netzel
 
Yes, the usual caveats is to forgot to close a connection when an exception
is raised. That said it looks like unlikely you have so much exceptions that
the problem appears immediatly.

In debug mode you could also register these connections to warn of unclaeand
connection at the end of the request.

As a side note I would stronly suggest to have a data access layer so that
you have only few open/close paris in your code...

Patrice
 
How can I register that in debug mode?

/Lars


Patrice said:
Yes, the usual caveats is to forgot to close a connection when an exception
is raised. That said it looks like unlikely you have so much exceptions that
the problem appears immediatly.

In debug mode you could also register these connections to warn of unclaeand
connection at the end of the request.

As a side note I would stronly suggest to have a data access layer so that
you have only few open/close paris in your code...

Patrice
 
Found the problem...

I found a Function that had a Return line (which then off course ends the
function) on the line before the Close command.. stupid!

/Lars
 
Back
Top