How to use BO.FillMultipleDataTables for parent, child, grandchild tables?


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
I am trying to fill the data for 3 BOs which will be used in a report, I am trying to use the BO.FillMultipleDataTables to get the data, but when creating the SQL for the grand child, I don't know how to reference the PK value in the SQL statement.

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 cmd

End Function

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.

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search