This documentation is archived and is not being maintained.

UniqueConstraint.Columns Property

Gets the array of columns that this constraint affects.

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

Property Value

An array of DataColumn objects.


[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)
    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.


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