Loading...

How to filter RDLC Report by date using two datetimepickers and a button in Winforms


I have created an RDLC report and inside the table adapter I've added a query and in the form that holds the report viewer I've added 2 datetimepickers and a button. Inside the button click event, I've added code to initialize the tableadapter and datatable.

I Used the same code to filter the report by a Shift and it worked using a textbox and a button, but I really need to filter the report by Date, Shift and Line. But I figured I'd start with the datetimepickers first. As you all can see from my code I don't even know how to build a query to include Date, Shift and Line.

This is the code inside the tableadapter query

SELECT        [DateTime], Inspector1, Inspector2, LineTech, Line, Shift, PartNumber, Ribbon1, Ribbon2, Ribbon3, RB1Scrap, RB2Scrap, RB3Scrap, RB4Scrap, RB5Scrap, RB6AScrap, RB6BScrap
FROM            ScrapRepairsEntry

WHERE DateTime between FromDate AND ToDate

This is the code inside the button click event

DsRibbonTableAdapters.ScrapRepairsEntryTableAdapter adapter = new DsRibbonTableAdapters.ScrapRepairsEntryTableAdapter();
      DsRibbon.ScrapRepairsEntryDataTable table = new DsRibbon.ScrapRepairsEntryDataTable();

      adapter.FillBy(table, dtpFrom.Text, dtpTo.Text);

      ReportDataSource MyNewDataSource = new ReportDataSource("DataSet1", (DataTable)table);
      this.reportViewer1.LocalReport.DataSources.Clear();
      this.reportViewer1.LocalReport.DataSources.Add(MyNewDataSource);
      this.reportViewer1.LocalReport.Refresh();
      this.reportViewer1.RefreshReport();

When I run the code, it throws an exception "No overload for method 'FillBy' takes 3 arguments". I've been searching Google and trying different things for days, but nothing works. I don't know what else to try.

- - Source
comments powered by Disqus