objectdatasource sqldatareader and conection pooling

G

Guest

Hi,

Recently, my site has been generating errors which say:
"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."

I'm wondering if this might have something to do with the way that we use
objectdatasource objects.

In an aspx page, we would put a gridview/dataview/whatever and bind it to an
objectdatasource.

The objectdatasource pulls data from a middle tier component which often
simply returns a sqldatareader object.

We're using the Enterprise Library's Data Access Application Block to handle
some of the data access functionality, and I believe that the DAAB
automatically sets the CommandBehavior.CloseConnection propperty.

However, because we are simply returning the datareader from the middle
tier, and passing them along to the objectdatasource on the aspx page, there
is no way (that I can think of) to call datareader.close or connection.close.

So, my question is: Does an objectdatasource close the datareader (and
connection) or is this all left open until the garbage collector comes along?

And if it is left open, is there simple way around this, or should I recode
the middle-tier to return datasets (or datatables or some other object) so
that I can close the connection manually?

thanks,
Doug
 
G

Guest

Seems clear to me that you've answered your own question. If you are getting
errors like this you can be pretty sure that those particular datareaders
aren't being closed and / or the connnections aren't being closed or Disposed.

DataSets, using a SqlDataAdapter which takes care of all this on its own, is
one good solution. There's a bit extra overhead over the straight reader but
in the big scheme of things you can find many other areas where optimization
can have much more effect - caching, etc.
Peter
 
G

Guest

Well, I hate answering my own question. :(

Uch, this is going to be a lot of very boring work.

Well, as long as I'm going to recode this, is there any reason to use a full
dataset, or could I save bit of memory overhead and just return a datatable
object?

thanks for answering,
Doug
 
H

heinz

Doug said:
Well, I hate answering my own question. :(

Uch, this is going to be a lot of very boring work.

Well, as long as I'm going to recode this, is there any reason to use a full
dataset, or could I save bit of memory overhead and just return a datatable
object?

thanks for answering,
Doug

seems imao to be a good case to use 'ASP.NET Output Caching with SQL
Server '
(not page caching).
wawens
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top