【问题标题】:Report Viewer doesn't show any data after publish报告查看器在发布后不显示任何数据
【发布时间】:2012-08-23 09:15:10
【问题描述】:

您好,我正在使用 C# 2010 和 sql server compact edition 3.5 来构建我的数据库,我使用报告向导从我的数据库生成报告,但不幸的是,在我发布应用程序后,我的报告查看器没有显示任何内容即使我插入了一条新记录。这是我在报告查看器上简单显示数据的代码:

this.jadwalkuliahTableAdapter.Fill(this.Dataset.jadwalkuliah);

        this.reportViewer1.RefreshReport();

注意:报告查看器在调试过程中显示来自我的数据库的数据。

【问题讨论】:

  • 它是否显示报告标题,但没有数据?有没有检查(sql trace)查看是否正在查询数据库?
  • 当然可以。但是如何知道数据是否查询成功呢?你能告诉我怎么做吗?
  • 是本地报告(rdlc)还是服务器报告(rdl)?

标签: c# sql-server-ce


【解决方案1】:

您缺少的 ReportDataSource:

this.reportViewer.LocalReport.DataSources.Clear(); 
DataTable dt = new DataTable(); 
dt = this.inputValuesTableAdapter.GetData();     

Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource(dt.TableName, dt); 

this.reportViewer.LocalReport.DataSources.Add(rprtDTSource); 
this.reportViewer.RefreshReport(); 

在下面查看这个网站:

how can I load datatable as ReportDataSource? SO

Building Reports from a DataSet using ReportViewer c-sharp corner

Creating Dataset Dynamically in c# and passing to Report Viewer.. asp.net forum

最好的问候

【讨论】:

  • 我想知道为什么我使用sql server(不是ce版本)时不会发生这种情况?
  • 你的数据源没有问题..确保你的数据集/数据表有它的数据..stackoverflow.com/questions/8425551/…
  • 我已经尝试了你上面的代码,但也许你想在我发布应用程序后看到结果link
猜你喜欢
  • 1970-01-01
  • 2014-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-14
  • 1970-01-01
相关资源
最近更新 更多