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?
This discussion has been closed.
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:
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.NetValues passed via SetParameterValue(...) will automatically be included in the SQL query parameters (TableDataSource.Parameters) bound to [ParameterName]