Export (0) Print
Expand All

Constraints Collection Editor

Allows you to create and configure constraints (Constraint objects) in a dataset DataTable object. Constraints are rules that help preserve the validity of data in a table. You can create two types of constraints:

  • A Unique constraint guarantees that there are no duplicates in a specific column and allows you to define a primary key.
  • A Foreign key constraint allows you to define referential integrity between a parent and child table.

The Constraint Collection Editor is displayed when you are using the Properties window to configure a dataset on a form or component and follow this sequence:

  1. Edit the dataset's Tables collection.
  2. Select a table in the Tables Collection Editor and edit its Constraints property.

    The Constraints Collection Editor opens on top of the Table Collection Editor.

    Note   You can use the Constraints Collection Editor to define table constraints only in an untyped dataset. For typed datasets, you create constraints by editing the dataset class's schema.

    For more information creating constraints in dataset tables, see Adding Untyped Datasets to a Form or Component.

Add
Creates a new constraint. When you click the Add button, a list of possible constraint types appears (UniqueConstraint and ForeignKeyConstraint). When you select the type, the appropriate dialog box opens (Unique Constraint or Foreign Key Constraint) to help you create the constraint.
Edit
Displays the appropriate dialog box (Unique Constraint or Foreign Key Constraint) to allow you to change the constraint's properties.
Remove
Deletes the selected constraint from the collection.
Caution   You cannot undo this action.

See Also

DataTable.Constraints Property | Adding Untyped Datasets to a Form or Component

Show:
© 2015 Microsoft