Get the collection of relations that link tables, and allow navigation from parent tables to child tables.
[Visual Basic] Public ReadOnly Property Relations As RelationsCollection [C#] public RelationsCollection Relations {get;} [C++] public: __property RelationsCollection* get_Relations(); [JScript] public function get Relations() : RelationsCollection;
A RelationsCollection that contains a collection of DataRelation objects.
The following example prints the column name of all child tables through the Relations property.
[Visual Basic]
Private Sub PrintChildRelationRows() ' Declare variable to hold the row values. Dim strRowVals As String Dim myDataSet As DataSet ' Get the DataSet of a DataGrid that is displaying data of at least two tables. myTable = DataGrid1.DataSource ' Navigate using the Relations. Dim myRel As DataRelation Dim row As DataRow Dim col As DataColumn ' Print the names of each column in each table through the Relations. For Each myRel In myDataSet.Relations For Each col in myRel.ChildTable.Columns strRowVals &= col.ColumnName & vbcrlf Next Next ' Display results. Console.WriteLine(strRowVals) End Sub
DataSet Class | DataSet Members | System.Data Namespace | DataRelation | DataTable | RelationsCollection