Monday 9 December 2013

How to use DataSet vs DataTable

A DataSet holds one or more DataTables.
 
Example 1:
DataTable dt = new DataTable();
DataSet ds = new DataSet();
ds.Tables.Add(dt);
 
Example 2:
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
DataSet ds = new DataSet();
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);
DataTable = A table with rows and columns
DataSet = A set with datatables. Can hold one or more Datatables in it. A container of datatables. Not just it, in Dataset you can have relations between tables too. 

No comments:

Post a Comment