DataSet versus DataTable

T

tim

Hi,

I recently created a generic data access layer so I can use it in many
applications. It is designed to return datasets, datareaders, scalar
values... I recently have come across in an application that uses the data
access layer needing a datatable instead of a dataset. What I have been
doing is returning the dataset with only one datatable and then accessing
the datatable in code (ds.tables[0]). I have been thinking about changing
my data access layer to return datatables. However with that said, is it
worth the redesign? Will I see better performance? Do you think it is a
bad practice to fill a dataset with only one table?

Thanks
 
W

William Ryan eMVP

A dataset is a fancy collection of datatables. However, if you only have
one table, why create the collection if you don't have to? It's easier to
reference the table directly and makes the code more clear. I'd add it
personally, but it's probably not going to be a life or death difference.

HTH,

Bill
 
C

Cor

Hi Tim,

Just to give another idea about that than Bill.

When you using a datatset or a datatable, the only thing you tranport in
your program is the reference. And therefore I would keep it for the one
type of the design and only use that dataset. Than you can everything also
with the datatable as by instance write it to XML while if you take the
other approach you have to add again special things.

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