C# 报表查看器不显示数据集
我正在尝试开发一个Winform应用程序,使用C#和SQL作为数据支持 我被困在一个特别的地方 我有一个Winform报表查看器,它应该显示将使用两个C# 报表查看器不显示数据集,c#,sql,C#,Sql,我正在尝试开发一个Winform应用程序,使用C#和SQL作为数据支持 我被困在一个特别的地方 我有一个Winform报表查看器,它应该显示将使用两个日期时间选择器控件检索的数据。以下是我的代码: `SqlConnection dat = new SqlConnection(@"Data Source=2011-GOA-RCC3\SQLEXPRESS;Initial Catalog=IOB_Comm;Integrated Security=True"); dat.Open
日期时间选择器控件检索的数据。以下是我的代码:
`SqlConnection dat = new SqlConnection(@"Data Source=2011-GOA-RCC3\SQLEXPRESS;Initial Catalog=IOB_Comm;Integrated Security=True");
dat.Open();
SqlCommand dat1 = new SqlCommand();
dat1.Connection = dat;
dat1.CommandText = "Select * from DCR Where Comp_Date Between '"+ dateTimePicker1.Text +"' And '"+ dateTimePicker2.Text +"' Order By Comp_Date Asc" ;
dat1.ExecuteNonQuery();
SqlDataAdapter nb = new SqlDataAdapter(dat1);
DataSet mn = new DataSet();
nb.Fill(mn);`
现在代码运行良好,直到那里,然后我选择databind,至少可以说,在dataset和报表查看器之间。这是代码
DataTable dsts = new DataTable();
dsts.TableName = "dt";
dsts = mn.Tables[0];
this.reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
Microsoft.Reporting.WinForms.ReportDataSource rdc = new Microsoft.Reporting.WinForms.ReportDataSource("dt", dsts);
this.reportViewer1.LocalReport.DataSources.Add(rdc);
this.reportViewer1.RefreshReport();
dataGridView1.DataSource = mn.Tables[0];//to check if dataset has data.
这就是我的问题所在。代码符合得很好,但输出不是我所期望的。
我可以在Datagridview中查看数据,但不能在报表查看器中查看数据
你们能帮忙吗
提前谢谢。我自己设法解决了这个问题
我刚刚在rdlc报告中添加了一个组表,并使用默认数据集(使用设计向导创建)重新创建了所有datatable,以指向列/行数据
现在工作非常顺利,我可以在报表视图中查看所有查询的数据