Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know about dataset and datatable.

where and why i will use dataset or datatable. which one is best and why.

I have search in goolge. But finding lot of things.
Can any one discuss it in easy way.

Thanks in advance.
Posted

While it is not, by any imagination, the most complete set, I like to refer to the documentation on MSDN to get the gist of what represents, how do I use it, what are the methods it supports etc...

Take a look DataSet[^] , DataTable[^]
 
Share this answer
 
One line:
DataSet is collection of DataTables.

Above line itself is more than enough to explain what are they and where to use. Right?

In case not, then:
DataTable = A table with rows and columns
DataSet = A set with datatables. Can hold one or more Datatables in it. A container of datatables.
 
Share this answer
 
Comments
Espen Harlinn 20-Feb-11 7:34am    
My 5 - odd question comming from a Senior Engineer, Software
Sandeep Mewara 20-Feb-11 7:36am    
Is that so. Surely strange then!

BTW, thanks Espen. :)
OriginalGriff 20-Feb-11 7:37am    
You think he might have *lied* on his Professional Profile! Shock! :laugh:
Sandeep Mewara 20-Feb-11 13:32pm    
Shock now!!!
[no name] 20-Feb-11 13:28pm    
Mr Espen what type of answer it is?? I know about this. But i want to know both them deeply. I want to know which one is faster with quary.
The above answer cent per cent rigth

DataTable is a single Table containing row and columns

and DataSet is kind of a container of DataTables, which can have many DataTables, and each DataTable is DataSet can be identified by its zero-based index or string name.

C#
DataSet ds;

ds.Tebles[0] 

or

ds.Tables["tablename"]
 
Share this answer
 
Comments
Albin Abel 20-Feb-11 11:38am    
This is an repeatable of Sandeep's answer. Anyhow dataset is not only container of datatable, it also holds collection of relationships. Simply it is a disconnected (miniature?) of the database. You can do most of the op with dataset that you can do with database. Additionally it talk with database with an adapter. This Adapter pattern helps the dataset not dependent to a particular kind of database, but at runtime it can bind to any kind of DB, sqlserver or mySql....So that is the use of an adapter pattern. Only slight dependency would be then the structure of the dataset and the database. This way the dataset survives independently (disconnected) and talk to database whenever necessary at runtime, the adapter fits the thumb drive into the correct socket... excuse me for talking long.
Q.when a collection of data is returned from a strored procedure,does it automatically goes inside the dataset?can i retrive it directly by making object of dataset?
 
Share this answer
 
Comments
[no name] 10-Jul-15 14:41pm    
Exactly how is this a solution to this 4 year old question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900