Master/detail using SQL

edited 10:33AM in FastReport .NET
How can I link two tables for a master/detail reports if I need to use SQL statements instead of tables?

I see that for tables, I can create a relation, but how can I do it for SQL?

In FR4, I used something like "... WHERE IdCustomer = :IdCustomer ...." in the detail table.

Thank you

Comments

  • edited February 2010
    Hello,

    For example you have Customers (Id, Name) and Orders (CustomerId, OrderId, Orderdate) tables. Here is how you can link them (I use MS SQL syntax here):

    Customers table:
    select * from Customers
    

    Orders table:
    select * from Orders 
    where CustomerId = @id
    
    You need to create the parameter in this query (see http://fast-report.com/documentation/UserM...arameters.htm):
    Name = id
    DataType = int (the same type as CustomerId column)
    DefaultValue = 0
    Expression = [Customers.Id]

    Now you can use these tables in a master-detail report. The relation is not needed.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.