Here my code for Parent ->Child:
Public Shared Function ServiceCallMaintenance_AllData(ByVal PK_ServiceCalls As Integer, ByVal includeServiceCallRecord As Boolean) As SqlCommand '-- Establish Locals Dim cmd As New SqlCommand() '-- Determine if the Service Call record will be included If includeServiceCallRecord Then cmd.CommandText = "SELECT dbo.ServiceCalls.* FROM dbo.ServiceCalls WHERE dbo.ServiceCalls.PK_ServiceCalls = @PK_ServiceCalls;" End If '-- Add the Appliances query for the selected Service Call, ordered by the Appliance Service Date. cmd.CommandText &= "SELECT dbo.SC_Appliances.* FROM dbo.ServiceCalls " & _"INNER JOIN dbo.SC_Appliances ON (dbo.ServiceCalls.PK_ServiceCalls = dbo.SC_Appliances.FK_ServiceCalls) " & _"WHERE (dbo.SC_Appliances.FK_ServiceCalls = @PK_ServiceCalls)" & _"ORDER BY dbo.SC_Appliances.ServicedDate;" '-- Create the parms cmd.Parameters.AddWithValue("@PK_ServiceCalls", PK_ServiceCalls).SqlDbType = SqlDbType.Int '-- Return the results Return cmdEnd Function
cmd.CommandText =
cmd.CommandText &=
cmd.Parameters.AddWithValue(
This code works fine, but if I want to add a grandchild table SC_AppliancesItems which is related to SC_Appliances I don't know to make a reference to SC_Appliances.PK_SC_Appliances in the SQL statement to get all related records to fill the grandchild BO.
How can I accomplish that?
Please see attached relation diagram.
You both gave me enough to material to start working on this. Thanks!
Just to show you how your help pay off . Please take a look at the attached image to see my 1st RSS report. Thanks again for your continued support!