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
ChildColumns | An array of DataColumn objects representing the keys in the child table that participate in this relationship. |
ChildKeyConstraint | The 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. |
ChildTable | The child DataTable object. |
DataSet | The DataSet object this relationship belongs to. |
Nested | A boolean value that specifies whether child columns should be rendered as nested elements when the DataSet is saved as XML text. |
ParentColumns | An array of DataColumn objects representing the keys in the parent table that participate in this relationship. |
ParentKeyConstraint | The UniqueConstraint object that ensures that values in the parent column are unique. |
ParentTable | The parent DataTable object. |
RelationName | The name of this relationship. |
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext