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.
CREATE
-- RESULT SET #1-- Retrieve the service service call
-- RESULT SET #2-- Rerieve all of the appliances for the specified service call
-- RESULT SET #3-- Retrieve all of the appliance items for the service call
END
Next, you will use this sproc to populate your BOs. Genreally, I will create a base BBS which then exposes the child BO via a BBS and then that will have the grandchild in it exposed, etc. You just go as deep as you need to go.
cmd.CommandType = StoredProcedurecmd.Parameters.Add("@serviceCallPk", SqlDbType.Int).Value = ServiceCallPK
BusinessLayer.FillMultipleDataTables(cmd, _ ServiceCalls.BusinessObject, _ ServiceCalls.BusinessObject.Appliances.BusinessObject, _ ServiceCalls.BusinessObject.Appliances.BusinessObject.ApplianceItems.BusinessObject)
So, where trent has "ServiceCalls.BusinessObject.Appliances.BusinessObject" on his FillMulitpleDataTables, he has actually created an internal AppliancesBBS within his ServiceCallsBO. On the public property used to access that AppliancesBBS, you can set the filter on the Get, and it will handle the rest for you:
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!