报表查看器未加载,显示空白 – 运行本地RDLC文件
我遇到了报告服务的问题,在2005版本上运行本地rdlc文件。
我在HTML中有一个报表查看器设置为在本地运行,如下所示:
在代码中
// 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都提供了所有访问权限。
有没有人遇到类似这样的问题,有什么想法吗?
尝试使用简单的报告,有时reportviewer会抛出由无效的RDLC引起的exception并显示空报告。
还可以尝试调试项目并查看Visual Studio中的输出窗口:您将看到RDL引擎引发的警告,调查错误原因可能很有用。
我和VS2012有同样的问题,报告显示加载图像,然后加载完成后,报告为空白。 数据存在但未呈现。
解决方案:只需将Report AsyncRendering更改为False ,报告再次正常工作。
当我在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()
我有同样的问题,在我的情况下,我发现我提供的数据集实际上不是报告所期望的对象类型。
在我的情况下,报告期望一个业务对象,但我提供了一个SQL数据源。
当报表上的参数不允许为空或空白但未提供参数值时,我也遇到了同样的问题。
另请注意,为了在代码中设置数据源,必须在onload事件中完成,而不是在page_load事件中完成。
在我的例子中,ReportViewer控件不提供错误消息(EventViewer也没有ReportViewer控件体),只是空白页面。 我认为这很难找到并解决问题。 Yoel Halb的回答是我的关键!
名为IsReadyForRendering的属性为False。 在BOL中指的是参数主题。
我可以用代码检查整个参数的每个值(你可以从即时窗口执行它)
var parameters = ReportViewer1.LocalReport.GetParameters()
当您使用值“MissingValidValue”查看属性State时,您将找到有问题的参数
希望这可以帮助 !
这个花了一些时间来弄清楚,所以希望这些检查可以节省你一些时间:
1)validationweb.config
2)在将任何配置移动到代码之前,直接在设计视图中尝试报表查看器控件
硬编码报表查看器控件
3)validation脚本管理器是否在报表查看器之前的页面上
4)确保报告在本地或SSRS服务器上的设计查看器之外运行
5)确保报告对所有参数都有默认值! 需要参数且没有默认值的报告显示为空白。
在我的情况下,罪魁祸首是让参数与Allow null value = false(未选中)…不要问我为什么。
更改纸张或报表查看器的大小后将无法正常工作,您可以通过添加更多延迟来尝试我的解决方案
WaitControlDisplayAfter
有时您的数据太大而无法处理异步
有同样的问题。 花了一段时间才弄清楚,但事实certificate我不小心新建了reportViewer控制自己,所以当我设计表单时,我失去了Visual Studio Designer为我创建的内容,这就是为什么reportviewer控件一直空白 – 我从未在Visual Studio Designer的ReportViewer对象上设置任何属性。
愚蠢的错误,但花了很长时间才弄明白。
我花了很多天才弄清楚类似的问题。 也许这可以帮助别人。 我已经阅读了stackoverflow上的几乎所有线程,但是在这里阅读评论让我尝试了这一点。 在我的例子中,显示了前两行(参数row和row以及隐藏参数的选项),但是包含管理按钮和报告本身的行是空的。 单击“ View report
导致无法执行操作。
我所做的是加载包含参数的报表而不提供它们 – 我希望用户填写它们 – 在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(); }