paramasivam
paramasivam

Reputation: 113

What is the difference between a DataSet and a DataTable in .NET?

What is the difference between a DataSet and a DataTable in .NET?

Upvotes: 6

Views: 7237

Answers (3)

Dayo Ajayi
Dayo Ajayi

Reputation: 21

You could think of a Dataset as a database, within which there could be one or more tables. A DataTable would be one of the tables within that database.

So, in summary:

DataSet <--> Database

DataTable <--> a table within a database.

Upvotes: 1

Manoj Kumar Dwivedi
Manoj Kumar Dwivedi

Reputation: 1

Data Table Record Fetch only One Row table at a time. Data Set is a collection of table that means at a time multiple record.

Upvotes: -3

Jon Skeet
Jon Skeet

Reputation: 1500495

Basically a DataSet is a collection of DataTables, possibly including relationships between the tables.

From the documentation for DataSet:

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. You can also enforce data integrity in the DataSet by using the UniqueConstraint and ForeignKeyConstraint objects. For further details about working with DataSet objects, see DataSets, DataTables, and DataViews (ADO.NET).

So a DataSet itself doesn't contain the data - that's always within DataTables. The DataSet adds metadata, basically.

Upvotes: 11

Related Questions