Click here to Skip to main content
15,913,215 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
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:


C#
// 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");
Posted
Comments
Suvendu Shekhar Giri 3-Dec-15 13:59pm    
Check this if it helps :)
http://stackoverflow.com/a/9304075[^]
CHill60 4-Dec-15 5:36am    
In the code you're showing you're not actually passing the parameters paraClassID and paraSessID and the one you do pass has not been initialised (paraField)

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