我目前正在尝试将 rdl 报告动态发送到我的 ReportViewer .net 对象。

执行此操作时,我不断收到错误消息:尚未为数据源“等等”提供数据源实例

我试图在运行时在我的代码中定义“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>

我要做的只是从报告中“废话”中的表格中选择 *。我需要这个来工作,因为我有许多其他的报告实例需要在我的 ReportViewer 中显示。为什么微软不让这更容易?

预先感谢任何人...

最佳答案

ReportViewer 控件旨在在本地模式下使用 RDLC 报告文件,而不是 RDL 报告文件。 ReportViewer 控件仅用于呈现报告,因此会忽略可能存在的任何数据集和连接信息(即,如果您使用 RDL 文件而不是 RDLC 文件)。目的是创建任何连接、查询数据源、将结果放入 DataTables 并添加这些以在调用应用程序中为 reportViewer 控件创建 reportDataSource。

来自 MSDN:



更多信息:Adding and Configuring the ReportViewer Controls

另见:When to use RDLC over RDL reports?

关于c# - 尚未为数据源提供数据源实例,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4027411/

10-09 21:37