Skip to content
Report-Designer

Multiple data sets and one document per record

Load report rows from several sources and print a document for each voucher or customer.

Add named data sets

In the Data source dialog, select the procedure. If the extra results are missing, click Read all result sets. Enter any parameter values and click Run it to read all result sets. The designer runs the procedure once in a transaction and rolls it back. Name the extra results and click Use this procedure. In the report file, "resultSet": 1 reads the second result set. A named set can also define its own commandText on the same connection, matching report parameters by name.

Bands repeat over the main rows. A table can read a named data set. If your app already loaded the rows, pass them together with ReportData.

var data = ReportData.FromObjects(vouchers).With("lines", lines);
var pdf = await reports.RenderAsync("check-voucher", data, new { FromDate = from, ToDate = to }, ReportFormat.Pdf, ct);

If a required data set is missing, the engine reports its name, such as dataSet:lines.

In Design, clear the selection. In the One document per section on the right, enter a key such as {VoucherNo} in Field or expression. Order the main rows by that key in your query. Each run of consecutive rows with the same key gets its own report header, footer, running totals and copies. Turn off Restart page numbers to number the pages across the whole batch.

Use a flat result set

If the procedure returns one row per voucher line, use Map fields to map the lines data set to Main rows (one row per line). This sets "resultSet": 0 so the lines data set reads the main rows again. Use it in a linked lines table and turn on Print the details once per document ("printDetailsOnce": true). The first row supplies the voucher details and the table lists its lines. See dbo.rpt_CheckVoucherFlat in samples/Database/check-voucher-flat.sql for an example.