Using FastReport from command line with SQL variables

My SQL queries in FastReport take variables such as dates and numbers. How can I print such reports with variables using the command line?

Comments

  • dialog form???

  • Yes, we are currently using a dialog form. I wanted to know how to execute it from the command line while providing SQL variables.

    For example, I'm looking for a command like "FastReport.exe Query.frx /PRINT @data='01/01/2021'" in which @data would be used as a variable in Query.

  • there are 2 methods:

    1. pass the parameter to ado.net , register filtered data to fastreport
    2. pass the parameter to fastreport, eq: report.SetParameterValue(.. , ..), use script to filter the report
  • Hello!

    To solve your problem, you can create a small command-line utility in C# (.NET):

    using var report = new FastReport.Report();
    report.Load(args[0]);
    foreach (var arg in args.Skip(1))
    {
    var parts = arg.Split(“=”, 2);
    report.SetParameterValue(parts[0], parts[1]);
    }
    report.Prepare();
    report.Export(new FastReport.Export.Pdf.PDFExport(), ‘out.pdf’); // or report.Print() in FastReport.Net
    

    Values passed via SetParameterValue(...) will automatically be included in the SQL query parameters (TableDataSource.Parameters) bound to [ParameterName]

This discussion has been closed.