1

C# ASP.NET MVC web application - Crystal Report parameter fields are not showing value in report PDF.

ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/Reports"), "BOMCosting.rpt"));

rd.SetParameterValue("@vCom", CompanyID);
rd.SetParameterValue("@vItem", item);
rd.SetParameterValue("@t_citg", groups);
rd.SetParameterValue("@v_NItem", items);
rd.SetParameterValue("@vCust", Customer);

rd.SetDataSource(dt);               
rd.Refresh();

Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);

return File(stream, "application/pdf", FileName + ".pdf");
4
  • rd.SetParameterValue("@vCust", Customer) -> vCust value not showing in pdf. Sep 5, 2019 at 5:09
  • check parameters in your profile call whether it is passing correct @dhuv
    – Nijin P J
    Sep 5, 2019 at 5:36
  • yes, it is call same as above. Sep 5, 2019 at 6:44
  • Can you Verify your BOMCosting.rpt and check @dhuv? if that also not working, just try Set Datasource Location
    – Nijin P J
    Sep 5, 2019 at 6:45

2 Answers 2

0

**hey Can you please verify report with latest DB (if you are using stored procedure please verify), if report is not updated with latest please update option will be Available inenter image description here

0
0

You need to set the data source first before passing the parameter. As simple as that.

ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/Reports"), "BOMCosting.rpt"));

rd.SetDataSource(dt);               

rd.SetParameterValue("@vCom", CompanyID);
rd.SetParameterValue("@vItem", item);
rd.SetParameterValue("@t_citg", groups);
rd.SetParameterValue("@v_NItem", items);
rd.SetParameterValue("@vCust", Customer);

Stream stream = 
rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);

return File(stream, "application/pdf", FileName + ".pdf");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.