Set NULL to datetime parameter
Hi All,
I have a problem while trying to set "NULL" value to my datetime parameters.
I have two datetime parameters (AllowNull=True) on my report. (BeginDate and EndDate)
it works fine in preview mode in reporting design.
The problem occurs, if I try to set an emtpy value to these parameters in my asp.net application.
The code looks like;
Dim
repParams(1) As ReportParameterrepParams(0) =
New ReportParameter("BeginDate", String.Empty)repParams(1) =
New ReportParameter("EndDate", String.Empty)-----
ReportParameter method requires String parameters. If user set any datetime value, I am sending "String.Empty" value to my paramaters in order to set them as NULL. But I am getting "rsReportParameterTypeMismatch Error."
How Can I set NULL value to these parameters from asp.net application?
Thans alot in advance.
Answers
Well, a server trace reveals that when the Product Line Sales sample report accepts nulls for the date parameters and the NULL checkbox is selected, the Report Manager doesn't set the value of the date parameters at all.
<SetExecutionParameters xmlns="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices"><Parameters><ParameterValue>
<Name>ProductCategory</Name><Value>1</Value></ParameterValue><ParameterValue>
<Name>ProductSubcategory</Name><Value>2</Value></ParameterValue><ParameterValue>
<Name>StartDate</Name></ParameterValue><ParameterValue>
<Name>EndDate</Name></ParameterValue></Parameters><ParameterLanguage>en-US</ParameterLanguage></SetExecutionParameters>
If Nothing doesn't work, using the default constructor should work:
repParams(0) = New ReportParameter()
repParams(0).Name = "BeginDate" // omit the value
All Replies
Have you tried:
Dim repParams(1) As ReportParameter
repParams(0) = New ReportParameter("BeginDate", Nothing)
repParams(1) = New ReportParameter("EndDate", Nothing)
Thanks alot for your answer...
repParams(0) = New ReportParameter("BeginDate", Nothing)
thats make an error. Because, ReportParameter accept string parameters. Error:
Error 2 Overload resolution failed because no accessible 'New' is most specific for these arguments:
'Public Sub New(name As String, values() As String)': Not most specific.
'Public Sub New(name As String, value As String)': Not most specific.Well, a server trace reveals that when the Product Line Sales sample report accepts nulls for the date parameters and the NULL checkbox is selected, the Report Manager doesn't set the value of the date parameters at all.
<SetExecutionParameters xmlns="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices"><Parameters><ParameterValue>
<Name>ProductCategory</Name><Value>1</Value></ParameterValue><ParameterValue>
<Name>ProductSubcategory</Name><Value>2</Value></ParameterValue><ParameterValue>
<Name>StartDate</Name></ParameterValue><ParameterValue>
<Name>EndDate</Name></ParameterValue></Parameters><ParameterLanguage>en-US</ParameterLanguage></SetExecutionParameters>
If Nothing doesn't work, using the default constructor should work:
repParams(0) = New ReportParameter()
repParams(0).Name = "BeginDate" // omit the value
Hi again,
I tried to set parameter by omiting the value. But I got an error, "Value cannot be null".
I think the only way to set these parameters as string instead of using datetime.
Consturctors are waiting string values but I can make string, int, datetime parameters in report.
its strange and not usefull.. but its unfortunately so..
- What does the Nullable property of the parameter say? Is it indeed nullable?
- yes the "AllowNull = true" for datetime parameters, and I see the null checkbox near the datetimepicker control in preview.
Hi again Teo,
my problem is solved strangely :)
I deleted two date paremeters in my report to try something else. Then I created the datetime parameter again, and I used your code example without passing value again, and it works. like this;
repParams(1) =
New ReportParameter("BeginDate")Actually I was tried same code before but I was getting an error. I dont know, whats happened. but it works now..
Thanks alot for your help.
- What probably happened is that your parameter changes were not reflected on deploy (use the Report Manager to verify). Deployment favors adminstrators so the server parameter configuration is not updated/changed when you deploy the report definition. You need to blow out the report and redeploy or update the report parameter configuration programatically.


