设置参数RDLC报告C#

问题描述 投票:0回答:1

在我的rdlc报告中,我创建了参数测试。在表单中我写下代码来设置参数:

//Set Parameters
ReportParameter[] p = new ReportParameter[1];
p[0] = new ReportParameter("Test", "Testing");
currentBilling_rv.LocalReport.SetParameters(p);

// Provide datasource to report Current_Total_Billing.rdlc
ReportDataSource rds = new ReportDataSource("CurrentTotalBilling", dataset.Tables[2]);
currentTotalBilling_rv.LocalReport.DataSources.Clear();
currentTotalBilling_rv.LocalReport.DisplayName = "Current Total Billing";
currentTotalBilling_rv.LocalReport.ReportPath = ".\\Current_Total_Billing.rdlc";
currentTotalBilling_rv.LocalReport.DataSources.Add(rds);
currentTotalBilling_rv.RefreshReport();

当我运行程序时,我有异常

Microsoft.ReportViewer.WinForms.dll中发生未处理的“Microsoft.Reporting.WinForms.MissingReportSourceException”类型异常

附加信息:尚未指定报告定义的来源

请帮忙。

c# winforms rdlc
1个回答
0
投票

在您的代码中,您正在为名为ReportViewercurrentBilling_rv设置一个参数,而不是为currentTotalBilling_rv设置参数,该参数在下一行代码中使用。

如果currentBilling_rv名称正确,请验证currentBilling_rv.LocalReport.ReportPath是否已编译。

© www.soinside.com 2019 - 2024. All rights reserved.