Foreign Key Constraint Dialog Box
Allows you to place a foreign key constraint on one or more columns in a dataset table (a child table) that is related to another table (the parent table). A foreign key constraint can implement referential integrity between parent and child tables.
Note
You can use this dialog box to create a unique constraint only for an untyped dataset. For typed datasets, you create constraints by editing the dataset in the Dataset Designer. For more information, see How to: Create DataRelations with the Dataset Designer.
Name
Identifies the constraint. The name is used when referencing the constraint in code.Parent table
Specifies the name of the table in the dataset that is acting as parent (master) table.Child table
Specifies the name of the table in the dataset that is acting as the child (detail) table.Parent Columns
Specifies the column or columns that constitute the primary key in the parent table. If the parent table has multiple columns that make up the key, select each part of the key in a separate row of the grid.Child Columns
Specifies the column or columns in the child table that form a foreign key pointing to the parent table. If the parent table has only one primary key column, select the column in the child table that corresponds to it. If the parent table has multiple columns that make up the key, select all the child columns that constitute parts of the parent-table key.Update rule
Specifies how changes are made to child records when a parent record is updated in order to maintain referential integrity. For more information about the options you can select, see the Rule enumeration.Delete rule
Specifies how changes are made to child records when a parent record is deleted to maintain referential integrity. For more information about the options you can select, see the Rule enumeration.Accept/Reject rule
Specifies how changes are made to child records when changes to a parent record are accepted or rejected to maintain referential integrity. For more information about the options you can select, see the Rule enumeration.
Select the untyped dataset in the form or component.
In the Properties window, click the button in the Tables property to display the Tables Collection Editor.
In the Members list, select the table to define a constraint for.
Select the Constraints property and click the button next to (Collection).
In the Constraints Collection Editor, click Add and select ForeignKeyConstraint.