UniqueConstraint.Columns 属性

定义

获取此约束影响的列的数组。

public:
 virtual property cli::array <System::Data::DataColumn ^> ^ Columns { cli::array <System::Data::DataColumn ^> ^ get(); };
public virtual System.Data.DataColumn[] Columns { get; }
[System.Data.DataSysDescription("KeyConstraintColumnsDescr")]
public virtual System.Data.DataColumn[] Columns { get; }
member this.Columns : System.Data.DataColumn[]
[<System.Data.DataSysDescription("KeyConstraintColumnsDescr")>]
member this.Columns : System.Data.DataColumn[]
Public Overridable ReadOnly Property Columns As DataColumn()

属性值

一个 DataColumn 对象数组。

属性

示例

下面的示例返回 DataColumn 约束的对象 UniqueConstraint

Private Sub GetColsFromConstraint()
    Dim dataColumns() As DataColumn

    ' Get a named relation from a DataSet.
    Dim dataRelation As DataRelation
    dataRelation = DataSet1.Relations("CustomerOrders")

    ' Get the ParentKeyConstraint
    Dim uniqueConstraint As UniqueConstraint
    uniqueConstraint= dataRelation.ParentKeyConstraint

    ' Get the DataColumn objects being constrained.
    dataColumns = uniqueConstraint.Columns

    ' Print the column name of each column.
    Dim i As Integer
    For i = 0 to dataColumns.GetUpperBound(0)
       Console.Write(dataColumns(i).ColumnName)
    Next i
 End Sub

适用于

另请参阅