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

<<  December 2017  >>
MonTueWedThuFriSatSun
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

Category list

None

Page List

Month List

AuthorList