0
我试图制定一个winform应用程序与C#和SQL作为备份的数据。报告查看器不显示数据集
我被困在一个特定的地方。
我有一个Winform报表查看器,应该显示要使用两个datetimepicker control
检索的数据。这里是我的代码:
`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);`
现在的代码工作正常,直到那里,然后我去数据绑定,排序的,至少可以说,数据集和报表观众之间。这里是代码,..
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中的数据,但不能查看报告...
你们能帮忙吗?
在此先感谢。