Follow Us

Skip Navigation LinksHome > Articles > ADO.NET > DataSet and its Components Part 5

DataSet and its Components Part 5

this article explain about DataSet and its all components such as DataTable, DataColumn, DataRelation etc.

By Pankaj   On   Thursday, 19 June 2008

Page Views : 2733   |   Technologies : ADO.NET

Rating : Rated :
0
| More..

 

DataSet and its Components:
 
 
 
1. DataTable Object: A DataTable represents one table of in-memory relational data. DataTable 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. DataTable can reside alone or can be part of the DataSet.
Columns and constraints represent the schema, or structure of a table. 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.
 
2. DataColumn Object: DataColumn represent the column in the table we can specify the different behavior of the column such as auto increment, not null and default value of the column etc.
 
3. Constrained Object: A constraint is a rule used to maintain the integrity of the data in the DataTable. e.g. when you delete a value that is used in one or more related tables, a ForeignConstrained determines whether the values in the related tables are also deleted, set to null values, set to default values, or whether no action occurs. A UniqueConstraint on the other hand, just makes sure that all values within a particular table are unique.
A base Constraint constructor is not used. Using the UniqueConstraint constructor creates primary or unique key constraints, and using the ForeignKeyConstraint constructor creates foreign key constraints.
 
4, DataRow Object: DataRow represent the actual data as a record of the DataTable. 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.
 
5. DataRelation Object: DataRelation is used to relate two DataTable objects to each other through DataColumn objects. For example, in a Customer/Orders relationship, the Customers table is the parent and the Orders table is the child of the relationship. This is similar to a primary key/foreign key relationship.
Relationships are created between matching columns in the parent and child tables. That is, the DataType value for both columns must be identical.
When a DataRelation is created, it first verifies that the relationship can be established. After it is added to the DataRelationCollection, the relationship is maintained by disallowing any changes that would invalidate it. Between the period when a DataRelation is created and added to the DataRelationCollection, it is possible for additional changes to be made to the parent or child rows. An exception is generated if this causes a relationship that is no longer valid.
 
6. DataSet Object:
The DataSet is an in-memory representation of data retrieved from a database, 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 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.
A DataSet can read and write data and schema as XML documents. The data and schema can then be transported across HTTP and used by any application, on any platform that is XML-enabled.

Keywords :
Tags :
Rate This Article :

Comments :

blog comments powered by Disqus
User Login
Username :
Password :
Register Login

Forgot Password


Related Articles