A database table commonly has a column, or group of columns, that uniquely identifies each row in the table. This identifying column or group of columns is called the primary key.
一个数据表都有一个或者是若干个列,而每个表都可以有唯一标识列的字段,这些能够标识字段的列就是所谓的主键。

When you identify a single DataColumn as the PrimaryKey for a DataTable, the table automatically sets the AllowDBNull property of the column to false and the Unique property to true. For multiple-column primary keys, only the AllowDBNull property is automatically set to false.
当你为确定一个列为数据表的主键的时候,表会自动为该列设置非空的属性。如果主键的内容涵盖多个列,那么这些列也都为非空。

The PrimaryKey property of a DataTable receives as its value an array of one or more DataColumn objects, as shown in the following examples. The first example defines a single column as the primary key.

例子:
workTable.PrimaryKey = new DataColumn[] {workTable.Columns["CustLName"], workTable.Columns["CustFName"]};

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2021-06-07
  • 2021-09-06
相关资源
相似解决方案