报表查看器无法加载,显示空白区域 - 运行本地RDLC文件

13

我在报表服务中遇到了问题,无法在2005版本上运行本地rdlc文件。

我在HTML中设置了一个报表查看器来本地运行,如下所示:

 <rsweb:ReportViewer ID="ReportingServicesReportViewer" runat="server" Height="100%"
            ProcessingMode="Local" ShowParameterPrompts="False" Width="100%">
        </rsweb:ReportViewer>
在代码中。
// create SqlConnection
        SqlConnection myConnection = new SqlConnection(ConnectionString);
        myCommand.Connection = myConnection;
        SqlDataAdapter da = new SqlDataAdapter(myCommand);

        //get the data
        DataSet data = new DataSet();
        da.Fill(data);

        if (data != null && data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0)
        {
            ReportingServicesReportViewer.Visible = true;
            ltrStatus.Text = string.Empty;

            //provide local report information to viewer
            ReportingServicesReportViewer.LocalReport.ReportPath = Server.MapPath(Report.RDLCPath);

            //bind the report attributes and data to the reportviewer
            ReportDataSource rds = new ReportDataSource("DataSet1", data.Tables[0]);
            ReportingServicesReportViewer.LocalReport.DataSources.Clear();
            ReportingServicesReportViewer.LocalReport.DataSources.Add(rds);
            ReportingServicesReportViewer.LocalReport.Refresh();
        }
        else
        {
            ReportingServicesReportViewer.Visible = false;
            ltrStatus.Text = "No data to display.";
        }
当执行用于使用报表结果填充报表查看器的方法时,什么都没有出现,就好像报表查看器根本不存在一样。
到目前为止,我已经采取了以下措施进行故障排除:
- 检查事件查看器以获取错误信息,而这是我得到的唯一相关信息:[Domain]\sp_dbadmin 原因:无法打开明确指定的数据库。然而,我连接的用户是 sysadmin。我已经检查了并确定了这一点,因为我检查了 sys.server_role_members。 - 我尝试模拟已登录用户的身份,但无济于事。 - 我创建了一个具有 sysadmin 权限的特定用户,并从 IIS 和 SQL Server 2008 上赋予了所有访问权限。
是否有人遇到过类似的问题,有什么想法?
10个回答

9

我也曾遇到和VS2012相同的问题,报告显示加载图像,加载完成后报告为空白。数据存在但未呈现。

解决方案:只需将报告的AsyncRendering更改为False,报告就可以再次正常工作。


8

当我在rdlc中添加参数但未指定时,我遇到了同样的问题。我通过添加以下代码解决了这个问题。

Dim p_Date As Microsoft.Reporting.WebForms.ReportParameter
p_Date = New Microsoft.Reporting.WebForms.ReportParameter("DATE", txtDate.Text)
    Me.ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WebForms.ReportParameter() {p_Date})
    ReportViewer1.LocalReport.Refresh()

1
虽然代码示例不是很好,但你确切地找出了问题! - Adam

8
尝试使用简单的报表,有时候如果RDLC无效,报表查看器会出现异常并显示空报表。
还可以尝试调试项目并查看Visual Studio中的输出窗口:您将看到RDL引擎引发的警告,这可能有助于调查错误原因。

5
在我的情况下,ReportViewer控件没有提供错误消息(EventViewer或ReportViewer控件正文),只有空白页面。我认为这使得查找和修复问题变得困难。Yoel Halb的答案是我的关键!
一个名为IsReadyForRendering的属性为False。在BOL中参考参数主题。
我可以使用代码检查整个参数的每个值(您可以从即时窗口执行它)。
   var parameters = ReportViewer1.LocalReport.GetParameters()

当您查看属性状态并且值为“MissingValidValue”时,您将找到有问题的参数。
希望这能帮到您!

3
我也遇到了相同的问题,原来是我提供了一个数据集,但它实际上不是报表所期望的对象类型。
在我的情况下,报告需要一个业务对象,但我提供了一个SQL数据源。
当报告中存在不能为null或空白的参数,但未提供参数值时,我也遇到了这个问题。
另外,请注意,在代码中设置数据源必须在onload事件中完成,而不是在page_load事件中完成。

5
在我的情况下,我还遇到了一个问题,即报告参数为空时,它会加载空白报告。同时记得只有在(!this.IsPostBack)的情况下才加载报告,否则会陷入无限循环加载的状态。 - Ghlouw

2

这个问题花费了一些时间来解决,希望以下的检查可以为你节省时间:

1)验证 web.config 文件

<system.web>
  <httpHandlers>
    <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false" />
  </httpHandlers>

  <buildProviders>
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
 </buildProviders>
</system.web>

<system.webServer>
  <handlers>
    <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
  </handlers>
<system.webServer>

2) 在将任何配置移入代码之前,直接在设计视图中尝试报表查看器控件。

硬编码报表查看器控件

3) 确认脚本管理器在报表查看器之前出现在页面上。

4) 确保报表在设计视图之外运行,可以在本地或SSRS服务器上运行。

5) 请务必为所有参数设置默认值!需要参数但没有默认值的报表会显示为空白。


1
在我的情况下,罪魁祸首是具有“允许空值”= false(未选中)的参数...不要问我为什么。

你是如何修复这个问题的?你是如何设置允许空值的? - CowboyBebop

1

更改纸张大小或报表查看器的大小后,可能会导致其无法正常工作。您可以尝试我的解决方案,通过增加更多延迟来设置

WaitControlDisplayAfter

有时您的数据太大,无法进行异步处理。


0
我花了很多天的时间来解决类似的问题。也许这可以帮助到某些人。我几乎阅读了stackoverflow上的所有线程,但是在这里阅读评论让我尝试了一下。在我的情况下,前两行(参数行和隐藏参数选项的行)被显示出来,但包含管理按钮和报告本身的行为空。点击“查看报告”没有任何反应。

preview of auto generated HTML web page

我所做的是在Page_Load上加载具有参数但未提供它们的报告 - 我希望用户填写它们。
protected void Page_Load( object sender, EventArgs e )
{
    this.LoadReport();
}

private void LoadReport()
{
        // retrieve path param from "Reports/{path}" URL
        string reportPath = Request.QueryString[ "path" ] as string;
        string reportServerUrl = System.Configuration.ConfigurationManager.AppSettings[ "ReportServerUrl" ];

        this.MainReport.ProcessingMode = ProcessingMode.Remote;
        this.MainReport.ServerReport.ReportServerUrl = new Uri( reportServerUrl );
        this.MainReport.ServerReport.ReportPath = reportPath;
        this.MainReport.ServerReport.Refresh();
}

Page_Load代码更改为以下内容后,一切正常。

protected void Page_Load( object sender, EventArgs e )
{
    if ( !this.IsPostBack )
        this.LoadReport();
}

0

我曾经遇到过同样的问题。对我来说,花了一些时间才弄清楚,原来是我不小心自己 new 了 reportViewer 控件,因此当我设计表单时,失去了 Visual Studio Designer 为我创建的内容,这就是为什么报告查看器控件一直显示为空白 - 我从未在 Visual Studio Designer 的 ReportViewer 对象上设置任何属性。

愚蠢的错误,但花费了相当长的时间才找出来。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接