ConstraintName Property
Collapse the table of content
Expand the table of content

Constraint.ConstraintName Property

The name of a constraint in the ConstraintCollection.

[Visual Basic]
Public Overridable Property ConstraintName As String
public virtual string ConstraintName {get; set;}
public: __property virtual String* get_ConstraintName();
public: __property virtual void set_ConstraintName(String*);
public function get ConstraintName() : String;
public function set ConstraintName(String);

Property Value

The name of the Constraint.


Exception Type Condition
ArgumentException The Constraint name is a null value or empty string.
DuplicateNameException The ConstraintCollection already contains a Constraint with the same name (The comparison is not case-sensitive.).


The ConstraintCollection is returned by the Constraints property of the DataTable class.


[Visual Basic, C#, C++] The following example iterates through the ConstraintCollection of a DataTable and prints each ConstraintName.

[Visual Basic] 
Private Sub PrintConstraintNames(myTable As DataTable)
    Dim cs As Constraint
    For Each cs In  myTable.Constraints
    Next cs
End Sub

private void PrintConstraintNames(DataTable myTable){
   foreach(Constraint cs in myTable.Constraints){

 void PrintConstraintNames(DataTable* myTable){
    System::Collections::IEnumerator* myEnum = myTable->Constraints->GetEnumerator();
    while (myEnum->MoveNext())
       Constraint* cs = __try_cast<Constraint*>(myEnum->Current);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ 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

Constraint Class | Constraint Members | System.Data Namespace

© 2016 Microsoft