【问题标题】:.rdl report not showing in C#.rdl 报告未在 C# 中显示
【发布时间】:2015-07-22 04:30:33
【问题描述】:

我使用 SQL Server Business Intelligence Development Studio 2008 R2 创建了一个 rdl 报告。

我使用了一个简单的查询

Select top 10 id from login_user where client_id =3

预览显示数据如下

然后我创建一个带有报告查看器和命令按钮的 c# 窗口应用程序。 在按钮点击我写了下面的代码

SqlConnection conn = new SqlConnection(connstring);
DataSet dataset = new DataSet();
 conn.Open();
sqlcomm = new SqlCommand("Select top 10 id from login_user where client_id = "+ 32, conn);
SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlcomm);
dataAdapter.Fill(dataset);
this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Report1.rdl";
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("TotalSale", dataset.Tables[0]));
this.reportViewer1.RefreshReport();

它执行成功,但报表查看器没有显示它正在给出消息的报表

尚未为数据源提供数据源实例

是因为我使用的是 .rdl?只有 rdlc 与.net 一起使用?我被困在这里。

【问题讨论】:

  • 正确格式 请稍等...

标签: c# .net rdlc rdl


【解决方案1】:

在这一行

this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("TotalSale", dataset.Tables[0]));

将“TotalSale”替换为“DatSet1”

因为您在报表中的数据集名称是 DataSet1。

【讨论】:

  • 会做..它可以让我在 5 分钟后标记它..已经投票了 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多