无法生成rdlc报告

时间:2015-08-17 05:27:47

标签: c# asp.net c#-4.0 rdlc

我是rdlc的新手,我有一个由我们公司的前雇员开发的页面,我必须通过添加更多的rdlc报告来修改它。所以,我复制粘贴报告并使路径动态化。但是我收到了错误,即

  

本地报告处理期间发生错误。

这是我的代码。

if (oDataSet.Tables.Count > 0)
{
   oDataSet.Tables.Add(oDataTable);
   ReportDataSource rd = new ReportDataSource("Letter", oDataSet.Tables[0]);
   ReportDataSource rd1 = new ReportDataSource("DataSet1", oDataSet.Tables[1]);
   this.TemprptViewer.LocalReport.DataSources.Clear();
   this.TemprptViewer.LocalReport.DataSources.Add(rd);
   this.TemprptViewer.LocalReport.DataSources.Add(rd1);
   ReportParameter p2 = new ReportParameter("CurrentDate", DateTime.Today.ToString("MMMM dd, yyyy"));
   this.TemprptViewer.LocalReport.SetParameters(new ReportParameter[] { p2 });
   ReportParameter Reimbrs_payAnnual = new ReportParameter("Reimbrs_payAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["Reimbrs_payAnnual"].ToString()), 0).ToString());
   ReportParameter basicAnnual = new ReportParameter("basicAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["basicAnnual"].ToString()), 0).ToString());
   ReportParameter hraAnnual = new ReportParameter("hraAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["hraAnnual"].ToString()), 0).ToString());
   ReportParameter spl_allowAnnual = new ReportParameter("spl_allowAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["spl_allowAnnual"].ToString()), 0).ToString());
   ReportParameter tran_allowAnnual = new ReportParameter("tran_allowAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["tran_allowAnnual"].ToString()), 0).ToString());
   ReportParameter statutory_bonusAnnual = new ReportParameter("statutory_bonusAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["statutory_bonusAnnual"].ToString()), 0).ToString());
   ReportParameter fixed_grossAnnual = new ReportParameter("fixed_grossAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["fixed_grossAnnual"].ToString()), 0).ToString());
   ReportParameter Medi_ReimbursAnnual = new ReportParameter("Medi_ReimbursAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["Medi_ReimbursAnnual"].ToString()), 0).ToString());
   ReportParameter LTAAnnual = new ReportParameter("LTAAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["LTAAnnual"].ToString()), 0).ToString());
   ReportParameter Total_ReimburseAnnual = new ReportParameter("Total_ReimburseAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["Total_ReimburseAnnual"].ToString()), 0).ToString());
   ReportParameter pfAnnual = new ReportParameter("pfAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["pfAnnual"].ToString()), 0).ToString());
   ReportParameter gratuityAnnual = new ReportParameter("gratuityAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["gratuityAnnual"].ToString()), 0).ToString());
   ReportParameter total_retiral_benifitAnnual = new ReportParameter("total_retiral_benifitAnnual", Math.Round(Double.Parse(oDataSet.Tables[0].Rows[0]["total_retiral_benifitAnnual"].ToString()), 0).ToString());
   ReportParameter ctcWords = new ReportParameter("ctcWords", ctcWord);
   this.TemprptViewer.LocalReport.SetParameters(new ReportParameter[] { basicAnnual, hraAnnual, spl_allowAnnual, tran_allowAnnual, statutory_bonusAnnual, fixed_grossAnnual, Medi_ReimbursAnnual, LTAAnnual, Total_ReimburseAnnual, pfAnnual, gratuityAnnual, total_retiral_benifitAnnual, ctcWords, Reimbrs_payAnnual });
   page.Session["GridBind"] = "a";
   this.TemprptViewer.LocalReport.Refresh();
}

此行发生错误

  

本地报告处理期间发生错误

this.TemprptViewer.LocalReport.SetParameters(new ReportParameter[] { p2 });

1 个答案:

答案 0 :(得分:1)

确保ReportViewer不为空

Look at picture

填写报告数据源&报告数据实例

的ReportViewer

1-选择ReportViewer任务

2-选择数据源

3-填写报告数据源

4-填写报告数据实例