Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Actually i had access the data from database using disconnected architecture in ado.net

some code like as

C#
Dataset ds=new Dataset();

da.fill(ds)


we can write above code same as below but some difference there(concept is unique)

C#
DataTable dt=new DataTable();

da.fill(dt)


i want difference b/w dataset and datatable in this example.both concepts will work

i have doubt about dataset and datatable but you can use the these different

dataclasses in different situations

why should developers prefer the alternative class(datatable) in disconnected mode

how will works ? how the dataset and datatable will work.

please help me.

thank u

What I have tried:

i want difference b/w dataset and datatable in this example.both concepts will work

i have doubt about dataset and datatable but you can use the these different

dataclasses in different situations

why should developers prefer the alternative class(datatable) in disconnected mode

how will works ? how the dataset and datatable will work.
Posted
Updated 22-Jun-16 20:00pm

In simplest terms, a DataSet is a collection of DataTable objects and their relationships (DataRelation).

DataTables are collections of records, pretty much mirorring the concept of a table in a database.
 
Share this answer
 
Quote:
i want difference b/w dataset and datatable in this example.both concepts will work


If your Query or Stored procedure is returning a single table then you shall go for DataTable
C#
da.fill(dt)  // da - dataadapter , dt - datatable 

If it returns multiple tables then use DataSet
C#
da.fill(ds) // da- dataadapter, ds - dataset 

the number of table returned from the query/procedure will be assigned to the Number to DataTables inside the DataSet dynamically, which you can access the DataTable using the index of the table, as
C#
var table1  = ds.Tables[0]; // 1st Table
var table2 = ds.Tables[1]; // 2nd Table


for more info on theory part refer DataSet vs DataTable[^]
 
Share this answer
 
You have to know if you are working with typed dateset and data adapter, datetable is a part of dateset object.
 
Share this answer
 
It has been already answered[^] several times[^].
 
Share this answer
 

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