Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp.net vb.net main difference betwen datatable and dataset

Posted on 2009-04-04
8
Medium Priority
?
728 Views
Last Modified: 2012-05-06
Some times the DataTable and DataSet objects still make me a little confused, what is the main difference between them and when I use each.
0
Comment
Question by:rflorencio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24066504
From MSDN:
The DataSet, which is an in-memory cache of data retrieved from a data source, is a major component of the ADO.NET architecture. The DataSet consists of a collection of DataTable objects that you can relate to each other with DataRelation objects.  
 http://msdn.microsoft.com/en-us/library/system.data.dataset.aspx
0
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 400 total points
ID: 24066513
Also look to this diagram to understand that the dataset is a in-memory representation that can have one or more datatables.
http://msdn.microsoft.com/en-us/library/zb0sdh0b.aspx 
0
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 24066519
Datasets are essentially a collection of Datatables.  When you use them is based off of the data you are holding.  If you are dealing with one set of data, that would all go into one location, the DataTable would be better.  If you are dealing with a multitude of data that needs to be seperated or grouped a specific way, a DataSet is better.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 24

Accepted Solution

by:
Jeff Certain earned 1600 total points
ID: 24067600
In addition to the comments already posted...

1. You can bind girds, listboxes, etc to either a datatable or a dataset. If you bind to a dataset, you'll need to specify the DataMember (i.e. the tablename) in addition to the datasource. (Caveat: some third-party libraries will assumer that you want to bind to DataSet.Table(0) if you don't specify the DataMember.)
2. DataSet has a fair amount of overhead associated with it. DataTable does too, but it gets somewhat worse if you throw DataTable into the mix when you don't need to. You're better of using objects whenever possible.
3. DataTables don't scale well. If you're putting more than about 1000 entries into them, you'll want to use an alternative storage mechanism. See http://msdn.microsoft.com/en-us/library/dd364983.aspx
4. Keep in mind that DataTables are disconnected -- that is, changes to them don't immediately result in changes to the database; you'll have to explicitly update the database.
0
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 24067681
I didn't know about datatables having problems with items over 1k entries.  Thanks for that bit of info.
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 24067696
It's not so much that it has "problems" as the fact that it's slow doing DataTable.Select against tables that have more than a thousand or so entries... and painfully slow when you're in the 50K+ range. I should maybe have been more clear.
0
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 24067796
You were perfectly fine.  In fact, you have given me insight over a problem I had recently with reading in 250+k rows into a datatable and selecting against it.
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 24067807
Wonderful! Glad I could help on that.

If you haven't already, and you're targeting 3.5, you really, really want to look at LINQ as a possible performance improvement.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question