Oct
20
2010

Working with Child Parent Relationships in .Net

Single relations are easy to add to your current dataset with multiple tables.

objDataSet.Relations.Add("RelationName", objDataSet.Tables("ParentTableName").Columns("account no"), objDataSet.Tables("Details").Columns("account no"))

Multiple relations require that you create an array of the datacolumns and add them to the relations like so

Dim oParentColumns As DataColumn() = New DataColumn() {objDataSet.Tables("ParentTableName").Columns("COlumnName1"), objDataSet.Tables("ParentTableName").Columns("COlumnName2"), objDataSet.Tables("ParentTableName").Columns("COlumnName3")}

Dim oChildColumns As DataColumn() = New DataColumn() {objDataSet.Tables("ChildTableName").Columns("ChildCOlumnName1"), objDataSet.Tables(.TableName).Columns("ChildCOlumnName12"), objDataSet.Tables(.TableName).Columns("ChildCOlumnName3")}

Dim oRelation As DataRelation = New DataRelation("RelationName", oParentColumns, oChildColumns)

objDataSet.Relations.Add(oRelation)

Enjoy :)

Calendar

<<  October 2017  >>
MonTueWedThuFriSatSun
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

View posts in large calendar

Category list

None

Page List

Month List

AuthorList