niv Posted July 22, 2003 Posted July 22, 2003 I am unsure on how to retrieve data from tables 2 tables that are related through a relationship table.... This seems to confuse me...! TableOne -------- TableOneID TableOneDesc TableTwo -------- TableTwoID TableTwoDesc TableOne_TableTwo_Relationship ------------------------------ TableOne_TableTwo_RelID TableOneID TableTwoID I have related TableOne to TableOne_TableTwo_Relationship. Then I have related TableTwo to TableOne_TableTwo_Relationship. DataRelation TableOneToRelTable = dsTest.Relations.Add("T1ToRel", TableOne.Columns["TableOneID"], TableOne_TableTwo_Relationship.Columns["TableOneID"]); DataRelation TableTwoToRelTable = dsTest.Relations.Add("T2ToRel",TableTwo.Columns["TableTwoID"], TableOne_TableTwo_Relationship.Columns["TableTwoID"]); I am unsure on how to traverse though the set relationships to retrieve data. ie) I want to print out all TableTwoDesc that have been related to a specific TableOneID. Thanks for your help, niv Quote
karimgarza Posted July 22, 2003 Posted July 22, 2003 did you add the relationships to the dataset. here is what I do after I create the relations <code> 'get the parent and child columns parentCol = DS1.Tables(0).Columns(strFirstKey) childCol = DS1.Tables(1).Columns(strSecondKey) ' Create DataRelation. Dim relContractorDivisions As DataRelation relContractorDivisions = New DataRelation(RelationshipName, parentCol, childCol) ' Add the relation to the DataSet. DS1.Relations.Add(relContractorDivisions) 'Create a DataView mdat = New DataView(DS1.Tables(0)) </code> in here I am just setting up a relationship between the Contractor Table and a Division Table. Keep me posted to know how you are doing. sorry I can't provide the full example but I always belive that everybody needs a push in the right direction to get going. Best of Luck Quote You're either a one or a zero. Alive or dead.
niv Posted July 22, 2003 Author Posted July 22, 2003 thanks... I will try this out.. the example you provided will help a whole lot. Thanks again, niv Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.