System.Data Namespace ConstraintCollection Class
Adds the specified constraint to the collection.
[ VB ] Overloads Public Sub Add ( _ ByVal constraint As Constraint _ ) [ C# ] public void Add ( Constraint constraint ); [ C++ ] public: void Add ( Constraint* constraint ); [ JScript ] public function Add ( constraint : Constraint );
If the collection is successfully changed by adding or removing constraints, the CollectionChanged event occurs.
The following example adds a UniqueConstraint to the ConstraintCollection of a DataTable.
private void AddConstraint ( DataTable myTable ) { UniqueConstraint myUniqueConstraint; // assuming a column named "UniqueColumn" exists, and its Unique property is true. myUniqueConstraint = new UniqueConstraint ( myTable.Columns [ "UniqueColumn" ] ); myTable.Constraints.Add ( myUniqueConstraint ); }
Private Sub AddConstraint ( myTable As DataTable ) Dim myUniqueConstraint As UniqueConstraint ' assuming a column named "UniqueColumn" exists, and its Unique property is true. myUniqueConstraint = New UniqueConstraint ( myTable.Columns ( "UniqueColumn" ) ) myTable.Constraints.Add ( myUniqueConstraint ) End Sub
ConstraintCollection Members ConstraintCollection.Add Overload List UniqueConstraint ForeignKeyConstraint
© 2000-2010 Rey Nuñez All rights reserved.If you have any question, comment or suggestion about this site, please send us a note
You can help support asp.net.ph