DataSet or Multiple Connections (Using DataReader)

D

dwok

Hi All,

I have read through some of the posts that compare DataSets and
DataReaders but I did not come across an answer that addresses the
pros/con between using a DataSet or Multiple Connections to the
database for use with DataReaders.

Basically I have a DaraReader that contains records. I will call this
DR1 (DataReader 1). For each row in DR1 I need to query the database
for another set of records. Because the DataReader maintains the
connection to the Database, I would need to open another connection to
the database to handle this second query. What I am wondering is if it
would be better to hold the records currently in DR1 in a DataSet
rather than a DataReader. I would not have to worry about opening
multiple connections as the DataSet is disconnected. However, I know
that there is extra overhead in using a DataSet as opposed to a
DataReader. Since I would really not be using all the advanced features
of the DataSet is it a waste to use it as I described in this scenario?
Would it be better to use DataReaders and open a second connection?

Thanks for any feedback!

- dwok
 
C

Cor Ligthert [MVP]

Dwok,

Before we start helping you, can you tell us where you have gotten that this
what you write bellow is so much, that it should be a reason for your
(program) design, which in my opinion as I understand you well seems to
scream for datasets and dataadapters.
However, I know that there is extra overhead in using a DataSet as opposed
to a
DataReader.

Cor
 
D

dwok

Hello Cor,

I am not sure what you are asking here. Is it that I am overly
concerned about the impact of a DataSet? That may be my lack of
understanding on the complexities of DataSets. Perhaps they are not as
much of a resource liability as I have been led to believe.

Dwok
 
C

Cor Ligthert [MVP]

Dwok,
Perhaps they are not as
much of a resource liability as I have been led to believe.
That was what I was trying to say, I would go for the dataset/datatable in
the way you describe your problem, makes your program probably as well much
smaller and more readable.

I hope this helps,

Cor
 

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

Top