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

发布于 2024-12-09 19:09:50 字数 1910 浏览 0 评论 0原文

我在 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 原因: 无法打开显式指定的数据库。 。然而, 我正在连接的用户是系统管理员。我已经检查过并且 我确定因为我检查了 sys.server_role_members
  • 我尝试模拟登录用户,但无济于事
  • 我创建了一个具有 sysadmin 权限的特定用户,并授予了来自 IIS 和 sql server 2008 的所有访问权限。

有人遇到过问题吗与此类似,有什么想法吗?

I got a problem with reporting services, running local rdlc files on the 2005 version.

I have in the HTML a report viewer set to run locally as follows :

 <rsweb:ReportViewer ID="ReportingServicesReportViewer" runat="server" Height="100%"
            ProcessingMode="Local" ShowParameterPrompts="False" Width="100%">
        </rsweb:ReportViewer>

In the code

// 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.";
        }

When the method to populate the report viewer with the results of the report is executed, nothing comes up as if the report viewer is not even there.

What I did to trouble shoot till now:

  • Checked the event viewer for errors and this is the only thing related
    which I get, [Domain]\sp_dbadmin Reason:
    Failed to open the explicitly specified database. . However,
    my user which I am connecting is a sysadmin. I have checked that and
    am sure because I checked the sys.server_role_members
  • I tried impersonating the logged in user, to no avail
  • I created a specific user with sysadmin rights, and gave all access rights both from IIS and also on the sql server 2008.

Has anyone encountered a problem similar to this, any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

习ぎ惯性依靠 2024-12-16 19:09:50

我在 VS2012 中遇到了同样的问题,报告显示正在加载图像,然后加载完成后,报告为空白。数据存在但未呈现。

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

I had same problem with VS2012, report shows loading image and then after loading is complete, report is blank. Data exists but not rendered.

Solution : Simply change Report AsyncRendering to False and report works fine again.

好听的两个字的网名 2024-12-16 19:09:50

当我在 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()

I was getting the same problem when I add parameter in rdlc but not assigning it.
I solved by adding this code.

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()
不知在何时 2024-12-16 19:09:50

尝试使用简单的报告,有时reportviewer会抛出无效RDLC引起的异常并显示空报告。

还可以尝试调试项目并查看 Visual Studio 中的输出窗口:您将看到 RDL 引擎发出的警告,这可能有助于调查错误的原因。

Try using a simple report , sometimes reportviewer throws exception caused by invalid RDLC and shows an empty report.

Try also to debug the project and look at the output window in Visual Studio: you will see the warning raised bu the RDL engine, it could be useful to investigate the reason of the error.

缺⑴份安定 2024-12-16 19:09:50

就我而言,ReportViewer 控件不提供错误消息(EventViewer 或 ReportViewer 控件主体),只是空白页面。我认为这使得很难找到并解决问题。 Yoel Halb 的回答是我的关键!

名为 IsReadyForRendering 的属性为 False。 BOL 中指的是参数话题。

我可以使用代码检查整个参数的每个值(您可以从立即窗口执行它)

   var parameters = ReportViewer1.LocalReport.GetParameters()

当您查看值为“MissingValidValue”的属性 State 时,您会发现有问题的参数

希望这有帮助!

In my case, ReportViewer control does not provide error messages (EventViewer nor ReportViewer control body), just blank page. I think this make hard find and fix the issue. Yoel Halb's answer was my key!

A property called IsReadyForRendering was False. In the BOL refers to parameters topic.

I could inspect every value of the whole parameters with the code (you can execute it from immediate window)

   var parameters = ReportViewer1.LocalReport.GetParameters()

You will find the problematic parameter when you look the property State with the value "MissingValidValue"

Hope this helps !

寄居人 2024-12-16 19:09:50

我遇到了同样的问题,就我而言,事实证明我提供的数据集实际上并不是报告所期望的对象类型。

在我的情况下,报告需要一个业务对象,但我提供了一个 SQL 数据源。

当报表上的参数不允许为空或空白但未提供参数值时,我也遇到了同样的问题。

另请注意,为了在代码中设置数据源,必须在 onload 事件中完成,而不是在 page_load 事件中完成。

I had the same problem and in my case it turned out that I have supplied the a dataset that was not the actually the object type that the report expected.

In my situation the report expected a business object, but I have supplied a SQL Data source.

I also encountered this same problem when there was parameters on the report which were not allowed to be null or blank but the parameter values was not supplied.

Also note that in order to set a data source in code it has to be done in the onload event and not in the page_load event.

蹲墙角沉默 2024-12-16 19:09:50

这个问题需要一些时间才能弄清楚,所以希望这些检查能为您节省一些时间:

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) 确保报告的所有参数都有默认值!需要参数且没有默认值的报告显示为空白。

This one took some time to figure out, so hopefully these checks will save you some time:

1) Verify the 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) try the report viewer control directly in design view before moving any configuration into code

Hard-Coded Report Viewer Control

3) Verify that the script manager is on the page before the report viewer

4) Ensure that the report runs outside of design viewer, either locally or on the SSRS server

5) BE SURE THAT REPORT HAS DEFAULT VALUES FOR ALL PARAMETERS! Reports that require parameters and don't have default values show up blank.

指尖上得阳光 2024-12-16 19:09:50

就我而言,罪魁祸首是具有允许空值= false(未选中)的参数...不要问我为什么。

In my case the culprit was having parameters with the Allow null value = false (unchecked)... Don't asked me why.

谜兔 2024-12-16 19:09:50

更改纸张大小或报表查看器无法工作后,您可以通过添加更多延迟来尝试我的解决方案

等待控件显示之后

有时您的数据太大而无法异步

after changing size for paper or reportviewer won't work you can try my solution by adding more delay for

WaitControlDisplayAfter

sometimes your data too large to process for async

未央 2024-12-16 19:09:50

有同样的问题。我花了一段时间才弄清楚,但事实证明,我自己不小心新建了reportViewer控件,因此我丢失了Visual Studio设计器在设计表单时为我创建的内容,这就是为什么reportviewer控件一直显示为空白的原因 -我从未在 Visual Studio Designer 的 ReportViewer 对象上设置任何属性。

愚蠢的错误,但花了相当长的时间才弄清楚。

Had the same problem. Took a while to figure out for me but it turns out I accidentally new'ed the reportViewer control myself so I lost what the Visual Studio Designer had created for me when I designed the form and that is why the reportviewer control kept coming up blank - I never set any properties on the Visual Studio Designer's ReportViewer object.

Silly mistake but took quite some time to figure out.

落花随流水 2024-12-16 19:09:50

我花了很多天来解决类似的问题。也许这可以帮助某人。我已经阅读了 stackoverflow 上的几乎所有帖子,但是阅读这里的评论让我尝试了这一点。在我的例子中,显示了前两行(参数行和带有隐藏参数选项的行),但包含管理按钮和报告本身的行是空的。单击查看报告不会导致任何操作。

预览自动生成的 HTML
网页

我所做的是在 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();
}

I've spent many days to figure out similar issue. Maybe this could help someone. I've read almost all threads on stackoverflow, but reading comments here made me try this out. In my case first two rows (parameters row and row with option to hide parameters) were shown, but rows that contain management buttons and the report itself were empty. Clicking View report resulted in no action.

preview of auto generated HTML
web page

What I've done was loading the report that had parameters without providing them - I wanted user to fill them - on 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();
}

After changing Page_Load code to the given below everything works fine.

protected void Page_Load( object sender, EventArgs e )
{
    if ( !this.IsPostBack )
        this.LoadReport();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文