.DataBind will close a sqlDataReader??

R

Rob R. Ainscough

Any reason why?

I bind a DataReader to a DropDown and as soon as I execute the .DataBind()
then IsClose becomes true. Is this because the DataReader is a one way
street and when it has read thru the return results set it has no option
other than to close?
 
Y

Yahoo

IDataReader's are forward only, read-only, data access objects. DataBinding
is going to read ever item and its data to its list. Since you can only go
forward it stands to reason that there is no longer a reason to hold the
connection to the data store open.

Database connections (and other kinds of connections) are expensive. Holding
a database connection open for any longer than necessary drastically effects
(i.e. nosedive) the scalability of your application. Scalability is
decreased because (1) typically database connections are pooled and their
numbers are typically low, and (2) since they are typically low numbers your
application could end up fighing with itself over this scarce resource.

While the details of your requirements are skimpy from your email, it sounds
like you are pulling back lookup info to populate the dropdowns, if possible
either (prefered) cache that lookup info OR load it into an XML doc (not
dataset) in the data access layer and bind that.

Joe
MCAD
SRE (Simple Rule Engine)
https://sourceforge.net/projects/sdsre/
 

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,774
Messages
2,569,596
Members
45,142
Latest member
DewittMill
Top