Share via


How to: Restrict a Data Column to Contain Unique Values

You set a DataColumn to contain unique values by adding a unique constraint to a data table. Unique constraints are also called keys. Marking a column as a Primary Key in the Dataset designer will create a Unique Constraint. For more information, see How to: Set a Data Column as the Primary Key.

To constrain a column to contain unique values

  1. Open your dataset in the Dataset Designer.

  2. Right-click the column you want to constrain to unique values. Point to Add, and then click Key.

  3. Verify that the correct column is selected in the Unique Constraint dialog box.

  4. Replace the default name of the constraint with a more meaningful name, if desired. For more information, see Unique Constraint Dialog Box.

See Also

Tasks

How to: Set a Data Column as the Primary Key

Walkthrough: Displaying Data on a Form in a Windows Application

How to: Connect to Data in a Database

How to: Set the Data Type of a DataColumn

How to: Change the Caption of a DataColumn

How to: Add Columns to a DataTable

How to: Create an Autonumber DataColumn

Concepts

What's New in Data

Dataset Designer

Reference

DataTable

Other Resources

Validating Data