Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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

You're either a one or a zero. Alive or dead.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...