FastReports / FastReport

Free Open Source Reporting tool for .NET6/.NET Core/.NET Framework that helps your application generate document-like reports

Home Page:https://www.fast-report.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Given Parameter not working

salmanshafiq00 opened this issue · comments

I am using FastReport Opensource edition. I design a report with simple query,

SELECT *
FROM [Identity].Users
WHERE Id = @id

Define a parameter by name id.

then in controller action write following code:

            await Task.Delay(0);
            FastReport.Utils.Config.WebMode = true;
            Report report = new();
            var mssqlConnection = new MsSqlDataConnection();
            mssqlConnection.ConnectionString = _config.GetConnectionString("DefaultConnection");
            report.Dictionary.Connections.Add(mssqlConnection);
            string path = $@"{_env.WebRootPath}\reports\personalData.frx";
            report.Report.Load(path);
           var loginUserId = HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
            report.SetParameterValue("id", loginUserId);
            if (report.Report.Prepare())
            {
                PDFSimpleExport pdfExport = new()
                {
                    ShowProgress = true,
                    Subject = "User Personal Data",
                    Title = "User Personal Data"
                };
                using MemoryStream ms = new();
                report.Report.Export(pdfExport, ms);
                report.Report.Dispose();
                pdfExport.Dispose();
                ms.Flush();
                return File(ms.ToArray(), "application/pdf", "personal-data.pdf");
            }

Problem is that, if I am using parameterized query report, any data not showing in the report But I use simple query without filter that works fine. What should to do now?

ff
fff
![ffff](https://github.c
fffff
om/FastReports/FastReport/assets/103124821/d4902cbe-ea09-4d72-9cc0-610aa4234fbd)
ffffff
fffffff

Your second picture shows an "Expression" box that is blank.
In that field you need to put your parameter that is passed to the report.
image

@salmanshafiq00 Is this issue still relevant?