Home All Groups Group Topic Archive Search About

Getting All Parent Records For Known Child (Double Primary Key)

Author
20 Apr 2006 12:05 PM
Aziz
I need a way to populate a DataTable withparent rows when the child row
is known in a double primary key situation. This is my XML Schema,
currently dealing in the two tables below, second one has two primary
keys:
http://img81.imageshack.us/img81/3697/datasetscreen11lb.jpg

BASEMETALSTOCKS
BaseMetalCode (PK)

BASEMETALALLOYS
AlloyCode (PK)
BaseMetalCode (PK and FK)


I can use the following code to get all the parent records for all
child records.

  Dim rowAlloy As DataRow
        Dim rowStock As DataRow
        For Each rowAlloy In dsTurbobraze.BaseMetalAlloy.Rows
            Dim drMetalDetails As DataRow
            drMetalDetails = dtMetalDetails.NewRow
            drMetalDetails("AlloyCode") = rowAlloy("AlloyCode")

            For Each rowStock In
rowAlloy.GetParentRows("BaseMetalStocks_BaseMetalAlloy")
                drMetalDetails("BaseMetalCode") =
rowStock("BaseMetalCode")
                drMetalDetails("BaseMetalPercent") =
rowAlloy("BaseMetalPercent")
                drMetalDetails("BaseCostPerGram") =
rowStock("BaseCostPerGram")
                dtMetalDetails.Rows.Add(drMetalDetails)
                dgrMetalDetails.DataSource = dtMetalDetails
            Next
        Next

But how do I get all the parent records for ONLY 1 child record PK?
(i.e. when AlloyCode is J176 get all related records). If it was just a
single primary key I could call the FindByXXXXXX method, but in my
situation I have to specify both AlloyCode and BaseMetalCode, whih
defeats the purpose of my question.

AddThis Social Bookmark Button