Click here to Skip to main content
15,511,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am using VS 2013 C# and MS-ACCESS DB.
I wana filter my RDLC report with date parameter but with only a year. I couldnt find the code for RDLC. All i could find was for .rdl for SSRS but my case is different.
Objective:
RDLC report will be filtered with Catagory, and current Year and User can also filter it with prev. years. But the default value for date parameter will be Current year.
ISSUE:
I have defined a custom format in Access DB as 'yyyy' then in DataSet1 i have added in Fill method as Fill(Cat, Year). Previously i was filtering the report with only Catagory and used following code:
this.DataTable1TableAdapter.Fill(this.DataSet1.DataTable1, comboBox1.Text);
Was working fine. On Report1.rdlc there are two row grps Parent grp: Catagory and child grp: Faculty. on winform i have 1 combobox for CAT and 1 textbox for Year then from report data window i have added date parameter(Session) and also st its default value through xpression builder as DateTime.Now. and used the following code:

DataSet1TableAdapters.DataTable1TableAdapter ta = new DataSet1TableAdapters.DataTable1TableAdapter();
DataSet1.DataTable1DataTable dt = new DataSet1.DataTable1DataTable();
ta.Fill(dt, comboBox1.Text, Convert.ToDateTime(textBox1.Text));
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet1";
rds.Value = dt;

ReportParameter rp = new ReportParameter("Session", textBox1.Text.ToString());
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.LocalReport.Refresh();
bt its throwing th exception 'String is not recognized as valid 'datetime'
Can't i filter the report with custom format i.e. yyyy? I have also removed the parameter and tried it with follwoing simple code:

this.DataTable1TableAdapter.Fill(this.DataSet1.DataTable1, comboBox1.Text, Convert.ToDateTime(textBox1.Text));
this.reportViewer1.RefreshReport(); showing
An error occurred during local report processing!
Should i aslo add a row grp for year?Or on which grp should i add it parent grp 'catagory' or child grp 'faculty'??Please guide there are so many ways and i have tried so many. Please help me with ds m lost in codes now.

Thanx in advance,
Posted

1 solution

ReportParameter rp = new ReportParameter("@Session", textBox1.Text.ToString());

Try that
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900