RnR
RnR

Reputation: 209

Parameter setting issue in ssrs report from winforms

From my win form application i unable to pass int and date time as parameters,when i try to pass , the program giving error. so here i converted all my parameters as string and pass,but the report is accepting ,int,date time,date time as there parameters from the respective stored procedure.so it generating error report.

                  string ID = "1 ";
                 string DateStart= DateTime.Today.AddDays(-1).ToString();
                 string DateEnd= DateTime.Today.ToString();
rptParameters[0] = new Microsoft.Reporting.WinForms.ReportParameter("@ID", ID);
 rptParameters[1] = new ReportParameter("@DateStart", DateStart)    
 rptParameters[2] = new ReportParameter("@DateEnd", DateEnd);

Is there any solution to pass other than string parameters from winform to SSRS reports.

Upvotes: 0

Views: 1454

Answers (1)

Magnus Johansson
Magnus Johansson

Reputation: 28325

As you can see by the documentation (and the error message), the parameter value should be a string.
Use ID.ToString(), DateStart.ToString() and DateEnd.ToString() as your parameters.

rptParameters[0] = new ReportParameter("@ID", ID.ToString());
rptParameters[1] = new ReportParameter("@DateStart", DateStart.ToString());    
rptParameters[2] = new ReportParameter("@DateEnd", DateEnd.ToString());

Upvotes: 1

Related Questions