Hello every body,
I'm writing a reporting application in WPF. Firstly I created the stored procedure in SQL server to collection infos with 2 parameters (@from and @to both date type).
I create a RDLC file in the same project with threes parameters: @from,@to(date) and @chuky (I mean period type likes daily,weekly...etc). Because I had two parameters in stored procedure, so I thought I didn't need to create filter in tablix in RDLC file.
Here is load report and set parameter functions.
DateTime from;
DateTime to;
if (!(DateTime.TryParse(dpFrom.Text, out from) && DateTime.TryParse(dpTo.Text, out to)))
{
MessageBox.Show("Please try again !!", "Data Exception", MessageBoxButton.OK, MessageBoxImage.Stop);
return;
}
Microsoft.Reporting.WinForms.ReportDataSource reportSource = new Microsoft.Reporting.WinForms.ReportDataSource();
NhaHangDataSet dataSet = new NhaHangDataSet();
dataSet.BeginInit();
reportSource.Name = "DataSet1";
reportSource.Value = dataSet.spReportMonAn;
_reportViewer.LocalReport.ReportEmbeddedResource = "Nhahang1.Reports.ReportMonAn.rdlc";
_reportViewer.LocalReport.DataSources.Add(reportSource);
dataSet.EndInit();
NhaHangDataSetTableAdapters.spReportMonAnTableAdapter adapter = new NhaHangDataSetTableAdapters.spReportMonAnTableAdapter();
adapter.ClearBeforeFill = true;
adapter.Fill(dataSet.spReportMonAn, from, to);
SetParameters(_reportViewer);
_reportViewer.RefreshReport(); private void SetParameters(ReportViewer rv)
{
ReportParameter[] parameters = new ReportParameter[3];
parameters[0] = new ReportParameter("from",dpFrom.Text);
parameters[1] = new ReportParameter("to", dpTo.Text);
parameters[2] = new ReportParameter("chuky", ((ComboBoxItem)cbbxPeriod.SelectedItem).Tag.ToString());
rv.LocalReport.SetParameters(parameters);
}Everything works well.
But now is the problem. Let's see the first
and the second image.
As you can see, with the same date condition but not the same data display.
The first image: firstly I created report with coditions are from 10-4-2014 to 10-4-2014 these conditions gave no data display, then I changed the time to (10-4-2011 to 10-4-2014) which is hoped display data, but no data displayed,it updated condition but didn't update the data.
The second image: I opened new windows and filled the codition (10-4-2011 to 10-4-2014) at once and the data displayed in the second image.
Question: Is there any problem in my C# code. Thanks for reading.
Please help me.
yenthuan