Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi. I'm trying to pass an image path to a parameter in Crystal Report where I used this parameter to fill in the picture object in the report.
However when I tried to pass the image path to crystal report parameter using c#, I get this error: String reference not set to an instance of a String.

Here is my code:
I referenced:
C#
using CrystalDecisions.Web;
using CrystalDecisions.Reporting;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.IO;
 

string qryStr = Request.QueryString["report"].ToString(); //I get the filename based on the querystring of the URL e.g EmployeeNo902706
ReportDocument rpt = new ReportDocument();
string rptPath = "../Reports/SampleReportPicture.rpt";
rpt.Load(Server.MapPath(rptPath));
string a = "C:\\inetpub\\wwwroot\\ISMPayroll_Reports\\" + qryStr + ".bmp";
crParameterDiscreteValue.Value = a;
crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["PicturePath"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

Page.Response.Clear();
Page.Response.Buffer = true;
MemoryStream os = (MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Page.Response.ContentType = "application/pdf";
Page.Response.BinaryWrite(os.ToArray());
Page.Response.End();
rpt.Close();
rpt.Dispose();


However, the image does not change. Any help?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900