Problem with connection pool

D

DaM

Hi guys,

I'm having this problem with my ASP.Net application:

I was testing the whole site, and it seem to work fine. Fast and
stable, but suddenly it stopped working and this error occurred:

"Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached."

What could be the cause? Every time I use a dataReader I'm pretty sure
I'm closing it.

Thanks in advance,
Dam
 
K

Kevin Spencer

Hi Dam,

First of all, "pretty sure" is never sure enough! But let's assume for a
moment that you ARE closing all of your DataReaders.

There are a limited number of database connections available in any
Connection Pool. These Connections are created as needed, until the Maximum
Pool Size is reached. There is one Connection Pool created for each unique
Connection String used. When a database operation is requested, the
Connection String used is checked against the available Connection Pools. If
an existing Connection is available, it is re-used. If there are no
Connections available, the request is queued until either a Connection is
released, or the Timeout period expires.

A Connection is released not by closing a DataReader only, but by closing a
Connection object. Closing a DataReader releases the Connection object from
the DataReader, but does not close it. A Connection is released when you
call Close or Dispose on the Connection object.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
G

Guest

You can always use ExecuteReader(CommandBehaviour.Close) to close connection
automatically when calling IdbDataReader.Close().
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top