dataset or datatable

alaric

Well-known member
Joined
Oct 12, 2005
Messages
53
Programming Experience
Beginner
I was wondering whats best to use for performance reasons.

when I add a gridstyle to my datagrid, I can use a ds or a dt as my datasource.

but whats the pro/cons for using one or the other? performance?
Or do I have more option when I use ie the ds instead of a dt?

can someone help me with some answers?


thanks in advance
 
DataTables are what store the information, there seems to be much confusion with regards to this matter. So i'll try to clear this up. As i have stated above a datatable stores al lthe information from your queries. It acts much like the tables you have in access. A dataset can hold a one, or a collection of datatables and is for creating a 'scaled down' in memory relational database. As for performance, The only advantage i can se is that if you don't need a dataset then it's just one less object for your app to instantiate and one less to dispose of, So i suppose it would be faster to not have a datset. But i doubt the difference is great. T he dataset does expose a few methods that the datatable doesn't, i.e 'Get Changes' and a datatable can't read or write XML. It al depends on what yuo require your app to do and then choose the appropriate components accordingly.
 
Just one point to clear up from vis781's post, which was otherwise excellent: the DataTable class does have a GetChanges method. Here's my recommendation.

Use just DataTables if all you want is the data with no relationships and you only have up to three or four tables.
Use a DataSet if you have five or more DataTables, need to use DataRelations between tables, need to read and/or write XML, need to pass data to or from a Web Service or need strongly-typed data.
 
Back
Top