DataTables (ADO.NET)
A DataSet is made up of a collection of tables, relationships, and constraints. In ADO.NET, DataTable objects are used to represent the tables in a DataSet. A DataTable represents one table of in-memory relational data; the data is local to the .NET-based application in which it resides, but can be populated from a data source such as Microsoft SQL Server using a DataAdapter For more information, see Populating a DataSet from a DataAdapter (ADO.NET).
The DataTable class is a member of the System.Data namespace within the .NET Framework class library. You can create and use a DataTable independently or as a member of a DataSet, and DataTable objects can also be used in conjunction with other .NET Framework objects, including the DataView. You access the collection of tables in a DataSet through the Tables property of the DataSet object.
The schema, or structure of a table is represented by columns and constraints. You define the schema of a DataTable using DataColumn objects as well as ForeignKeyConstraint and UniqueConstraint objects. The columns in a table can map to columns in a data source, contain calculated values from expressions, automatically increment their values, or contain primary key values.
In addition to a schema, a DataTable must also have rows to contain and order data. The DataRow class represents the actual data contained in a table. You use the DataRow and its properties and methods to retrieve, evaluate, and manipulate the data in a table. As you access and change the data within a row, the DataRow object maintains both its current and original state.
You can create parent-child relationships between tables using one or more related columns in the tables. You create a relationship between DataTable objects using a DataRelation. DataRelation objects can then be used to return the related child or parent rows of a particular row. For more information, see Adding DataRelations (ADO.NET).
In This Section
Creating a DataTable (ADO.NET)
Explains how to create a DataTable and add it to a DataSet.DataTable Schema Definition (ADO.NET)
Provides information about creating and using DataColumn objects and constraints.Manipulating Data in a DataTable
Explains how to add, modify, and delete data in a table. Explains how to use DataTable events to examine changes to data in the table.Handling DataTable Events (ADO.NET)
Provides information about the events available for use with a DataTable, including events when column values are modified and rows are added or deleted.
Related Sections
ADO.NET
Describes the ADO.NET architecture and components, and how to use them to access existing data sources and manage application data.DataSets, DataTables, and DataViews (ADO.NET)
Provides information about the ADO.NET DataSet including how to create relationships between tables.Constraint Class
Provides reference information about the Constraint object.DataColumn Class
Provides reference information about the DataColumn object.DataSet Class
Provides reference information about the DataSet object.DataTable Class
Provides reference information about the DataTable object..NET Framework Class Library Overview
Provides an overview of the .NET Framework class library, including the System namespace as well as its second-level namespace, System.Data.