How To Add 2 Relations to dataset ?

Posted On // Leave a Comment



I have two dataadapter in one dataset as shown.
1st dataset named "tblMaster"
2nd dataset named "tblDetail"



i use code below to create relations by Type Column (A)

Dim KeyPriTipe As DataColumn = dsRencanaAlokasi.Tables("tblMaster").Columns("Type")
Dim keyForTipe As DataColumn = dsRencanaAlokasi.Tables("tblDetail").Columns("Type")
dsRencanaAlokasi.Relations.Add("Detail", KeyPriTipe, keyForTipe, False)


 how can i add more relations (B) to dataset so the datasets linked by two relations, Type and Color?


''=======================================================================
i got my answer by myself. Array is the answer. heres the single code:



dsRencanaAlokasi.Relations.Add("NewRelation", New DataColumn() {dsRencanaAlokasi.Tables("Master").Columns("Tipe"), dsRencanaAlokasi.Tables("Master").Columns("Warna")}, _
                                                     New DataColumn() {dsRencanaAlokasi.Tables("Detail").Columns("Tipe"), dsRencanaAlokasi.Tables("Detail").Columns("Warna")})

0 komentar: