Represents a parent/child relationship between two DataTable objects.
Assembly: System.Data (in System.Data.dll)
A 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. For more information, see Navigating DataRelations (ADO.NET).
Relationships are created between matching columns in the parent and child tables. That is, the DataType value for both columns must be identical.
Relationships can also cascade various changes from the parent DataRow to its child rows. To control how values are changed in child rows, add a ForeignKeyConstraint to the ConstraintCollection of the DataTable object. The ConstraintCollection determines what action to take when a value in a parent table is deleted or updated.
When a 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 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.
Data corruption can occur if a bi-directional relation is defined between two tables. A bi-directional relation consists of two DataRelation objects that use the same columns, with the parent-child roles switched. No exception is raised when the DataRelation objects are saved; however, data corruption can occur.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.