Constraints Collection Editor

Allows you to create and configure constraints (Constraint objects) in a DataTable object. Constraints are rules that help preserve the integrity 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.

  • 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.

    Warning

    You cannot undo this action.

See Also

Reference

DataTable.Constraints

Concepts

What's New in Data Application Development

Binding Windows Forms Controls to Data in Visual Studio

Preparing Your Application to Receive Data

Fetching Data into Your Application

Binding Controls to Data in Visual Studio

Editing Data in Your Application

Validating Data

Saving Data

Other Resources

Data Walkthroughs

Overview of Data Applications in Visual Studio

Connecting to Data in Visual Studio