我已经创建了一个rdlc报告。我的表单上有一个reportViewer。当我尝试加载报告时,我得到:“尚未指定报告'xxxx.rdlc‘的报告定义”。我搞不懂这件事。我有一个datatable,其中包含报告所需的数据。我将这个dataTable加载回我的数据库,加载到一个名为"FinalReport“的表中。(我之所以这样做,是因为rdlc需要某种dataSource。)我的报告中有一个表格(table1)。这是我的代码(在我的窗体中,报表查看器所在的位置):
this.finalDataReportTableAdapter.Fill(this.nehasitDataSet.FinalDataReport);
localReport.ReportEmbeddedResource = @"Resources\VisibleAssets.rdlc";
//I'm not so sure about the following line, but it's the only line that prevented me from getting an error ("no reportdefinition defined"
using (StreamReader rdlcSR = new StreamReader(@"Resources\VisibleAssets.rdlc"))
{
localReport.LoadReportDefinition(rdlcSR);
localReport.Refresh();
}
this.reportViewer.RefreshReport();我还将报告连接到dataTable,并将reportViewer连接到报告。我真的看不出有什么问题,我在谷歌上搜索了一下。
任何帮助都将受到高度的感谢。
发布于 2019-08-02 08:18:04
如果您在代码中而不是报告路径中设置ReportEmbeddedResource属性,则将Build Action属性从XYZ.rdlc文件的属性更改为Embedded Resource将帮助您解决大部分问题。
https://stackoverflow.com/questions/8505700
复制相似问题