Export (0) Print
Expand All

UniqueConstraint.Columns Property

Gets the array of columns that this constraint affects.

[Visual Basic]
Public Overridable ReadOnly Property Columns As DataColumn ()
[C#]
public virtual DataColumn[] Columns {get;}
[C++]
public: __property virtual DataColumn* get_Columns();
[JScript]
public function get Columns() : DataColumn[];

Property Value

An array of DataColumn objects.

Example

[Visual Basic] The following example returns the DataColumn objects that the UniqueConstraint constrains.

[Visual Basic] 
Private Sub GetColsFromConstraint()
    Dim dCols() As DataColumn
    ' Get a named relation from a DataSet.
    Dim rel As DataRelation
    rel = DataSet1.Relations("CustomerOrders")
    ' Get the ParentKeyConstraint
    Dim cstrt As UniqueConstraint
    cstrt= rel.ParentKeyConstraint
    ' Get the DataColumn objects being constrained.
    dCols = cstrt.Columns
    ' Print the column name of each column.
    Dim i As Integer
    For i = 0 to dCols.GetUpperBound(0)
       Console.Write(dCols(i).ColumnName)
    Next i
 End Sub

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

UniqueConstraint Class | UniqueConstraint Members | System.Data Namespace

Show:
© 2014 Microsoft