This documentation is archived and is not being maintained.

UniqueConstraint.UniqueConstraint(String, DataColumn) Constructor

Initializes a new instance of the UniqueConstraint class with the specified name and DataColumn.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

public UniqueConstraint (
	string name,
	DataColumn column
)
public UniqueConstraint (
	String name, 
	DataColumn column
)
public function UniqueConstraint (
	name : String, 
	column : DataColumn
)
Not applicable.

Parameters

name

The name of the constraint.

column

The DataColumn to constrain.

The following example creates a new UniqueConstraint and assigns it to the ParentKeyConstraint property of a DataRelation.

Private Sub CreateUniqueConstraint(ByVal dataSetSuppliers As DataSet)
    Dim uniqueConstraint As UniqueConstraint

    ' Get the DataColumn of a table in a DataSet.
    Dim dataColumn As DataColumn
    dataColumn = dataSetSuppliers.Tables("Suppliers").Columns("SupplierID")

    ' Create the constraint.
    uniqueConstraint = New UniqueConstraint("supplierIdConstraint", dataColumn)

    ' Add the constraint to the ConstraintCollection of the DataTable.
    dataSetSuppliers.Tables("Suppliers").Constraints.Add(uniqueConstraint)
End Sub

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Show: