Click here to Skip to main content
15,921,351 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
See more:
Hello ,
I started to self study and stumbled upon "DataTable", "DataSet" and "DataGridView". I would like to know the difference between these three and how these three are related.?
Posted
Comments
Sergey Alexandrovich Kryukov 6-Jun-11 15:34pm    
What's the difference between apple and Apple? Invalid question, at least in its form.
--SA

SQL
A dataset is an in-memory representation of a database-like structure. It can have one or more datatable and define relations between them, key field etc.
A datatable is an in-memory representation of a single database table. You can think of it as having columns and rows in the same way.
A dataview is a view on a datatable, a bit like a sql view. It allows you to filter and sort the rows - often for binding to a windows form control.
 
Share this answer
 
DataGridView is a control which gets data from DataTable, DataView or Dataset.
DataTable is an in-memory table.
DataSet is a collection of DataTable objects.
 
Share this answer
 
Comments
beginner in C#.net 6-Jun-11 5:45am    
gud explanation... my 5
Monjurul Habib 6-Jun-11 12:25pm    
nice answer my 5.
Sergey Alexandrovich Kryukov 6-Jun-11 15:35pm    
Short and encouraging to learn them, my 5.
--SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Jun-11 15:35pm    
Good reading, my 5.
--SA
Monjurul Habib 6-Jun-11 15:59pm    
thank you.
hi.

try this links below.

dataset class
data grid
data table

hope it helps.
goodluck. :)


-chaosgray-
 
Share this answer
 
DataSet is in-memory representation of database (has views, tables, relations etc) whereas DataTable is in-memory representation of a "database table".
Whereas DataGridView is a control to display data to the user.
 
Share this answer
 
dataset is front end memory by using dataset we can get data from backend
and fill into DataAdapter.

Datatable is also same purpose like dataset but it use ful in runtime very much

datagridview useful to get data in table format.

See the following code

C#
sqldataadapter da= new SqlDataAdater("select * from Employee", con);
DataSet ds = new DataSet();
da.Fill(ds);
datagridview1.DataSource = ds.table[0];

C#
sqldataadapter da = new SqlDataAdater("select * from Employee", con);
DataTable dt = new DataTable();
da.Fill(dt);
datagridview1.DataSource = dt;
 
Share this answer
 
v2
Comments
Uday P.Singh 6-Jun-11 5:54am    
my dear friend, I don't think we fill Data adapter with Data set, in fact we fill Dataset with Data adapter. Data Adapter acts as a bridge between Database and Dataset. Data adapter works in a disconnected architecture.

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