System.Data.DataRelation

A DataRelation represents a relationship between two DataTable objects in the same DataSet.
This relationship is established between one or more fields in the parent (master) table and an equal number of fields in the child (detail) table.


Dim objDataRelation As System.Data.DataRelation 
Dim objDataColumn1 As System.Data.DataColumn
Dim objDataColumn2 As System.Data.DataColumn

objDataColumn1 = objDataSet.Tables("Table Name").Columns("Column Name")
objDataColumn2 = objDataSet.Tables("Table Name").Columns("Column Name")

objDataRelation = New System.Data.DataRelation("Relationship Name", objDataColumn1, objDataColumn2)
objDataSet.Relations.Add(objDataRelation)

Once you have defined the relationship (between two columns) you can add this relation to the DataSet.


Then create a DataViewManager object

Dim objDataViewManager As System.Data.DataViewManager 

objDataViewManager = objDataSet.DefaultViewManager

Check this line actually works

objDataGridView.DataSource = objDataViewManager 


Properties

ChildColumnsAn array of DataColumn objects representing the keys in the child table that participate in this relationship.
ChildKeyConstraintThe ForeignKeyConstraint object that ensures that values in the child table's foreign key column are equal to a value in the parent table's key field.
ChildTableThe child DataTable object.
DataSetThe DataSet object this relationship belongs to.
NestedA boolean value that specifies whether child columns should be rendered as nested elements when the DataSet is saved as XML text.
ParentColumnsAn array of DataColumn objects representing the keys in the parent table that participate in this relationship.
ParentKeyConstraintThe UniqueConstraint object that ensures that values in the parent column are unique.
ParentTableThe parent DataTable object.
RelationNameThe name of this relationship.

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext