SQL query parameters can be substituted with real values at run time. This example replaces a parameter value just before the data is fetched.

Supplying values. Create or resolve the input parameter, assign its value before rendering, and pass the prepared report to the viewer or export routine.
@Component({
    selector: "using-parameters-in-sql-query",
    imports: [Viewer],
    template: `<sti-viewer [report]="report"></sti-viewer>`
})

export class UsingParametersInSqlQuery {
    report: Stimulsoft.Report.StiReport;

    constructor() {
        Stimulsoft.StiOptions.WebServer.url = "http://localhost:9615/";

        this.report = new Stimulsoft.Report.StiReport();
        this.report.loadFile("Reports/SimpleListSQL.mrt");

        this.report.onBeginProcessData = function (args) {
            // You can change the SQL query parameters with the required values
            // For example: SELECT * FROM @Parameter1 WHERE Id = @Parameter2 AND Date > @Parameter3
            if (args.dataSource === 'customers') {
                args.parameters[0].value = 'Germany';
            }
        }
    }
}

In the onBeginProcessData event the query parameters are exposed through args.parameters; assigning value for the matching data source injects the run-time value into the SQL command.

Используя этот сайт, вы соглашаетесь на использование файлов Cookie для аналитики и персонализированного контента. Файлы Cookie хранят полезную информацию на вашем компьютере, чтобы помочь нам повысить эффективность и удобство использования. Для получения дополнительной информации, пожалуйста, прочтите Конфиденциальность и Использование Cookie.