ConstraintCollection.Add Method (String, DataColumn[], DataColumn[])

 

Constructs a new ForeignKeyConstraint, with the specified arrays of parent columns and child columns, and adds the constraint to the collection.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

member Add : 
        name:string *
        primaryKeyColumns:DataColumn[] *
        foreignKeyColumns:DataColumn[] -> Constraint

Parameters

name
Type: System.String

The name of the ForeignKeyConstraint.

primaryKeyColumns
Type: System.Data.DataColumn[]

An array of DataColumn objects that are the primary key, or parent, columns.

foreignKeyColumns
Type: System.Data.DataColumn[]

An array of DataColumn objects that are the foreign key, or child, columns.

Return Value

Type: System.Data.Constraint

A new ForeignKeyConstraint.

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.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: