Rows count of a linked table

DomiDomi Belgium
edited November 2018 in FastReport .NET
Hi,

I have 2 linked tables : "Customers" and "Transactions", Customers contains unique entry but the linked transactions can have 0 or x transactions per customers.
I need a list to display each customers and the number of transactions per customers without displaying any field of the transactions table

is there any function which returns the row number like 'select count(*) from ...'

how can I achieve this easily ?

thanks in advance,
Domi.

Comments

  • Hello!

    In the BeforePrint event of a master band (for example, Data1, bound to Customers), initialize the child data source based on the current master row and read the RowCount property:

    private void Data1_BeforePrint(object sender, EventArgs e)
    {
    DataSourceBase customers = Report.GetDataSource(“Customers”);
    DataSourceBase transactions = Report.GetDataSource(“Transactions”);
    transactions.Init(customers);
    TextCount.Text = transactions.RowCount.ToString();
    }
    

    If a DataRelation is specified in the DataSet (for example, “Customers_Transactions”), you can also retrieve the count using GetChildRows:

    private void Data1_BeforePrint(object sender, EventArgs e)
    {
    var rowView = (System.Data.DataRowView)Report.GetDataSource(“Customers”).CurrentRow;
    TextCount.Text = rowView.Row.GetChildRows(“Customers_Transactions”).Length.ToString();
    }
    
This discussion has been closed.