1

I am trying to export a report in pdf that requires two parameter values "paraSessID" and "paraClassID". It worked perfectly on machine before I included connection for the report. But now all I get is the "missing parameter values" on deployment.

Below is the code:

// creating object of crystal report
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath("~/termreport/first.rpt")); 
// path of report

// Once I have the data I need to apply it to the connection of the report
ConnectionInfo crConnection = new ConnectionInfo();
crConnection.UserID = "";
crConnection.ServerName = "";
crConnection.DatabaseName = "";
crConnection.Password = "";

AssignConnectionInfo(crystalReport, crConnection);

crystalReport.SetDatabaseLogon(crConnection.UserID, crConnection.Password, crConnection.ServerName, crConnection.DatabaseName);
crystalReport.SetDataSource(dss.Tables[0].DefaultView); // binding dataset

ParameterFields paraField = new ParameterFields();
ParameterField paraSessID = new ParameterField();
ParameterField paraClassID = new ParameterField();
ParameterDiscreteValue paraSessDiscrete;
ParameterDiscreteValue paraClassDiscrete;

paraSessID.Name = "paraSessID";
paraSessID.CurrentValues.Clear();
paraSessDiscrete = new ParameterDiscreteValue();
paraSessDiscrete.Value = SessID;
paraSessID.CurrentValues.Add(paraSessDiscrete);
paraField.Add(paraSessID);

paraClassID.Name = "paraClassID";
paraClassID.CurrentValues.Clear();
paraClassDiscrete = new ParameterDiscreteValue();
paraClassDiscrete.Value = ClassID;
paraClassID.CurrentValues.Add(paraClassDiscrete);
paraField.Add(paraClassID);

CrystalReportViewer1.ParameterFieldInfo = paraField;

//crystalReport.SetParameterValue("paraSessID", SessID);
//crystalReport.SetParameterValue("paraClassID", ClassID);

CrystalReportViewer1.ReportSource = crystalReport;
//CrystalReportViewer1.RefreshReport();

crystalReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "First Term Report");
haraman
  • 2,744
  • 2
  • 27
  • 50
femrock
  • 11
  • 3
  • 1. You are assigning parameters to `CrystalReportViewer`, instead apply them to ReportDocument i.e. `crystalReport` 2. Try implementing `ApplyCurrentValues` also. For more details check [how-to-pass-values-to-two-different-parameters](http://stackoverflow.com/questions/33127714/how-to-pass-values-to-two-different-parameters). (Its VB.NET but can easily be converted to C#) – haraman Dec 03 '15 at 11:33

0 Answers0