Represents a constraint that can be enforced on one or more DataColumn objects.
Assembly: System.Data (in System.Data.dll)
Thetype exposes the following members.
|CheckStateForProperty||Infrastructure. Gets the DataSet to which this constraint belongs.|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|SetDataSet||Sets the constraint's DataSet.|
|ToString||Gets the ConstraintName, if there is one, as a string. (Overrides Object::ToString().)|
A constraint is a rule used to maintain the integrity of the data in the DataTable. For example, when you delete a value that is used in one or more related tables, a ForeignKeyConstraint 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. For more information, see DataTable Constraints (ADO.NET).
A base constructor is not used. Primary or unique key constraints are created by using the UniqueConstraint constructor, and foreign key constraints are created by using the ForeignKeyConstraint constructor.
The following example examines the collection of constraints for a DataTable and determines whether each constraint is a UniqueConstraint or a ForeignKeyConstraint. The properties of the constraint are then displayed.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.