Bagikan melalui


How to: Set a Data Column as the Primary Key

Setting a data column as the primary key guarantees that each record contains a unique value. Only one primary key can be assigned to a data table. You create a primary key in a data table using the Dataset Designer.

To set a data column to be the primary key in a data table

  1. Open your dataset in the Dataset Designer.

  2. Right-click the column you want to set as the primary key. Click Set Primary Key.

    A key icon appears next to the selected column(s).

See Also

Tasks

Walkthrough: Displaying Data on a Form in a Windows Application

How to: Connect to Data in a Database

How to: Change the Caption of a DataColumn

How to: Set the Data Type of a DataColumn

Concepts

What's New in Data

Dataset Designer

Reference

DataTable

DataColumn

Other Resources

Data Walkthroughs

Validating Data