Crystal Reports ASP.NET C#中缺少参数值

时间:2015-12-03 06:31:12

标签: c# asp.net parameters crystal-reports

我正在尝试以PDF格式导出报告,该报告需要两个参数值" paraSessID"和" paraClassID"。在我包含报告连接之前,它在机器上完美运行。但现在我得到的是"缺少的参数值"部署。

以下是代码:

// 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");

0 个答案:

没有答案