我目前正在尝试动态地向我的ReportViewer .net对象发送一个rdl报告。
当我这样做时,我一直会得到错误:数据源实例还没有提供给数据源"blah“。
我试图在运行时在我的代码后面定义"blah“。
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = ReportFile;
ReportViewer1.LocalReport.DataSources.Clear();
Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
rds.Name = "blah";
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.DocumentMapCollapsed = true;
ReportViewer1.LocalReport.Refresh();--这不是一个长远的目标,。我不知道我该怎么做。下面是我的rdl文件顶部的摘录:
<DataSource Name="blah">
<rd:DataSourceID>c6a8409e-71a4-4e96-86ad-b300a5b942c3</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>Data Source=10.555.121.121;Initial Catalog=blah</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>我所要做的只是简单地从我的报告中的"blah“中的一个表中选择*。我需要这样做,因为我需要在我的ReportViewer中显示许多其他的报告实例。为什么微软不让这件事变得更容易呢?
事先谢谢大家..。
发布于 2015-06-24 23:06:37
ReportViewer控件设计为在本地模式下处理RDLC报表文件,而不是RDL报表文件。ReportViewer控件仅用于呈现报表,因此忽略可能存在的任何数据集和连接信息(即,如果您使用的是RDL文件而不是RDLC文件)。其目的是创建任何连接、查询数据源、将结果放入DataTables并添加这些结果以创建调用应用程序中的reportViewer控件的reportDataSource。
来自MSDN:
在本地处理模式中,控件打开报表定义,对其进行处理,然后在视图区域中呈现报表。在本地处理模式下,可以从文件系统上的.rdlc文件、流或应用程序中的嵌入式资源获取报表定义。
更多信息:添加和配置ReportViewer控件
https://stackoverflow.com/questions/4027411
复制相似问题