bob jason tiamsic

bob jason tiamsic

  • NA
  • 12
  • 7.7k

passing a path to crystal report parameter for Picture objec

Jul 7 2015 5:26 AM
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:
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));
CrystalDecisions.CrystalReports.Engine.ReportClass clsPic = new CrystalDecisions.CrystalReports.Engine.ReportClass();
clsPic.SetParameterValue(2, "C:\\inetpub\\wwwroot\\ISMPayroll_Reports\\" + qryStr + ".bmp"); --I GET THE ERROR HERE
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();
 
Can someone help me with this? 

Answers (1)