UniqueConstraint.IsPrimaryKey 속성

정의

제약 조건이 기본 키에 있는지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsPrimaryKey { bool get(); };
public bool IsPrimaryKey { get; }
[System.Data.DataSysDescription("KeyConstraintIsPrimaryKeyDescr")]
public bool IsPrimaryKey { get; }
member this.IsPrimaryKey : bool
[<System.Data.DataSysDescription("KeyConstraintIsPrimaryKeyDescr")>]
member this.IsPrimaryKey : bool
Public ReadOnly Property IsPrimaryKey As Boolean

속성 값

제약 조건이 기본 키에 있으면 true이고, 그렇지 않으면 false입니다.

특성

예제

다음 예에서는 속성을 확인합니다 IsPrimaryKey .

Private Sub GetPrimaryKey()
    Dim dataRelation As DataRelation
    Dim uniqueConstraint As UniqueConstraint

    ' Get a DataRelation from a DataSet.
    dataRelation = DataSet1.Relations("CustomerOrders")

    ' Get the ParentKeyConstraint.
    uniqueConstraint = dataRelation.ParentKeyConstraint

    ' Test if the IsPrimaryKey is true.
    If uniqueConstraint.IsPrimaryKey Then
       Console.WriteLine("IsPrimaryKey=True")
    Else
       Console.WriteLine("IsPrimaryKey=False")
    End If
 End Sub

설명

테이블에는 일반적으로 모든 행이 고유하도록 하는 기본 키가 포함됩니다. 일부 테이블에서는 기본 키가 둘 이상의 열로 구성될 수 있습니다. 예를 들어 이름이 포함된 테이블의 기본 키는 이름과 성으로 구성될 수도 있습니다. 둘 이상의 열이 있는 기본 키를 만들려면 Columns 속성을 DataColumn 개체의 배열로 설정합니다.

적용 대상

추가 정보