DataTable::PrimaryKey Property
Gets or sets an array of columns that function as primary keys for the data table.
Assembly: System.Data (in System.Data.dll)
public: property array<DataColumn^>^ PrimaryKey { array<DataColumn^>^ get(); void set(array<DataColumn^>^ value); }
| Exception | Condition |
|---|---|
| DataException | The key is a foreign key. |
The primary key of a table must be unique to identify the record in the table. It's also possible to have a table with a primary key made up of two or more columns. This occurs when a single column can't contain enough unique values. For example, a two column primary key might consist of a "FirstName" and "LastName" column. Because primary keys can be made up of more than one column, the PrimaryKey property consists of an array of DataColumn objects.
Available since 1.1