【发布时间】:2011-04-30 22:56:44
【问题描述】:
我目前正在尝试将 rdl 报告动态发送到我的 ReportViewer .net 对象。
执行此操作时不断收到错误消息:尚未为数据源“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 中显示许多其他报表实例。为什么微软不让这更容易?
提前谢谢大家...
【问题讨论】:
-
你不需要 ReportViewer1.DataBind(); 吗?
-
感谢您的建议,解决方案并不容易,我必须解析 rdl 的 XML 并检索 sql 并从中构建数据源,然后将数据源命名为与 rdl 完全相同的名称, 之后一切都开始工作了。
-
你所做的似乎很有趣。也许你应该详细说明你做了什么作为答案然后接受它?
标签: c# reportviewer reporting-services