This documentation is archived and is not being maintained.

DataRelation.RelationName Property

Gets or sets the name used to retrieve a DataRelation from the DataRelationCollection.

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

Property Value

The name of the a DataRelation.


Exception Type Condition
ArgumentException A null reference (Nothing in Visual Basic) or empty string ("") was passed into a DataColumn that is a DataRelation.
DuplicateNameException The DataRelation belongs to a collection that already contains a DataRelation with the same name.


Use the RelationName property to retrieve a DataRelation from the DataRelationCollection.


[Visual Basic] The following example uses the RelationName property to retrieve a DataRelation from a DataRelationCollection.

[Visual Basic] 
Private Sub GetRelation()
    Dim dRels As DataRelationCollection
    ' Get the collection of a DataSet
    dRels = DataSet1.Relations
    ' Add a relation named CustomerOrders
    Dim myRel As DataRelation
    myRel = dRels("CustomerOrders")
    ' Just to make sure, print the RelationName.
 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

DataRelation Class | DataRelation Members | System.Data Namespace | DataSet | DataRelationCollection | Item