SQL report: null parameter

I found that there might be a problem in SQL Reporting. I have a ReportViewer on my page and I submit the parameters using the following method:

List<ReportParameter> myParams = new List<ReportParameter>();

myParams.Add(new ReportParameter("Start_Date", StartDate));
myParams.Add(new ReportParameter("End_Date", EndDate));

ReportViewer1.ServerReport.SetParameters(myParams);

It works great! But, when I try to set the parameter to null, after executing this request, it saves the previous value, and does not set its value to null.

I fire this code in another event that executes after the above code:

List<ReportParameter> myParams = new List<ReportParameter>();

myParams.Add(new ReportParameter("Start_Date")); 
// I even tried omiting this line.  
//(This is the null parameter I wish to pass)
myParams.Add(new ReportParameter("End_Date", EndDate));

ReportViewer1.ServerReport.SetParameters(myParams);

Can anyone find a job or other technique to make it work?

Also, if I do not initially define a parameter, then I assign a parameter, then I do not define a parameter, it supports the value that was assigned. (These are all callbacks, every event)

+5
3

- . , , .

List<ReportParameter> myParams = new List<ReportParameter>();

ReportParameter p = new ReportParameter("Start_Date");
p.Values.Add(null);
myParams.Add(p);

//myParams.Add(new ReportParameter("Start_Date")); 
// I even tried omiting this line.  
//(This is the null parameter I wish to pass)
myParams.Add(new ReportParameter("End_Date", EndDate));

ReportViewer1.ServerReport.SetParameters(myParams);
+7

:

ReportViewer1.Reset();

?

+3

Are StartDate and EndDate variables of type DateTime? Perhaps this is due to the fact that DateTime variables cannot be null, instead they are DateTime.MinValue. Try setting the DateTime.MinValue parameter and process it accordingly.

0
source

All Articles