NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataColumn.Unique

Gets or sets a value indicating whether the values in each row of the column must be unique.

[Visual Basic]
Public Property Unique As Boolean
[C#]
public bool Unique {get; set;}
[C++]
public: __property bool get_Unique();
public: __property void set_Unique(bool);
[JScript]
public function get Unique() : Boolean;
public function set Unique(Boolean);

Property Value

true if the value must be unique; otherwise, false. The default is false.

Exceptions

Exception Type Condition
ArgumentException The column is a calculated column.

Remarks

The OnPropertyChanged event occurs when the property change is successful.

You can also add a UniqueConstraint to the DataTable to which this column belongs to ensure the values are unique.

Example [Visual Basic]

The following example creates a new DataColumn and sets its Unique property to true.

[Visual Basic]

Private Sub MakeUniqueColumn()
   Dim myColumn As DataColumn
   Dim myTable As New DataTable
   myColumn = New DataColumn
   myTable = New DataTable
   ' Set the Unique property of the DataColumn.
   myColumn.Unique = True
   ' Add the column to the table.
   myTable.Columns.Add myColumn
   ' Add the Table to a DataSet.
   DataSet1.Tables.Add(myTable)
End Sub

See Also

DataColumn Class | DataColumn Members | System.Data Namespace | AllowNull | UniqueConstraint | Constraints