ConstraintCollection::Add Method (String^, array<DataColumn^>^, array<DataColumn^>^)
.NET Framework (current version)
Constructs a new ForeignKeyConstraint, with the specified arrays of parent columns and child columns, and adds the constraint to the collection.
Assembly: System.Data (in System.Data.dll)
public: Constraint^ Add( String^ name, array<DataColumn^>^ primaryKeyColumns, array<DataColumn^>^ foreignKeyColumns )
Parameters
- name
-
Type:
System::String^
The name of the ForeignKeyConstraint.
- primaryKeyColumns
-
Type:
array<System.Data::DataColumn^>^
An array of DataColumn objects that are the primary key, or parent, columns.
- foreignKeyColumns
-
Type:
array<System.Data::DataColumn^>^
An array of DataColumn objects that are the foreign key, or child, columns.
The CollectionChanged event occurs if the constraint is added successfully.
The following example creates two arrays of DataColumn objects, and then creates two ForeignKeyConstraint relationships between two tables in a dataset.
.NET Framework
Available since 1.1
Available since 1.1
Show: