SSRS 2005 Report Manager: Error when trying to raise an error using parameters validated by embedded code
I am having a problem when trying to display an error message for an ssrs report parameter which is deployed in report manager.
The best answer I found for this problem was authored by Jin Chen, Microsoft Employee Moderator in May 2009.
I precisely followed his directions but continue to receive the same error.
The report parameters in question include the start_date and end_date.
The check_dates parameter (via a non queried default value) simply references the code to validate the dates [ =code.CheckDates(Parameters!start_date.Value,Parameters!end_date.Value) ].
The CheckDates code (under the Report Properties Reference tab) is:
public function CheckDates(SDate as Date, EDate as Date) as integer
Dim msg as String
msg = ""
if (SDate > EDate) then
msg = "ERROR. Start Date must fall before the End Date."
else
if datePart("yyyy", SDate) <> datePart("yyyy", EDate) then
msg = "ERROR. Dates must be within the same calendar year."
end if
end if
if msg <> "" then
System.Web.HttpContext.Current.Response.Write("<script language='javascript'>alert('" & "Date Error!"
&"');</script>")
err.raise(6,Report)
return -1
end if
end function
I added the appropriate assembly (under the Report Properties Reference Assembly name):
System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
I am calling report manager on an application server from my virtual machine.
My virtual machine does not have a “rssrvpolicy.config” file – only the rspreviewpolicy.config and rsreportdesigner.config files.
However, the application server does feature that “rssrvpolicy.config” file which I have changed to allow FullTrust permission.
Old:
<CodeGroup
class="FirstMatchCodeGroup"
version="1"
PermissionSetName="Execution"
Description="This code group grants MyComputer code Execution permission. "> …
New:
<CodeGroup
class="FirstMatchCodeGroup"
version="1"
PermissionSetName="FullTrust"
Description="This code group grants MyComputer code Execution permission. "> …
I continue to receive an unresolved error rather than the controlled error message:
Error during processing of ‘check_dates’ report parameter. (rsReportParameterProcessingError)
Please help!
What am I doing incorrectly?
June 20th, 2011 7:51pm
Hi Sherry,
To my understanding, the most important part of this post is to raise a secified error code. In the code, the err.raise(6,report) means Overflow.
I did not find anything incorrect from the code mentioned above, but I think it is not a good idea to use
System.Web.HttpContext.Current.Response.Write. Although, it can work sometime in SSRS 2005, but if you decide to upgrade the SQL server, those code might not work as expected.
Meanwhile, I do not have a SSRS 2005 environment at this moment, but I did the same test on SSRS 2008 R2, and the code works for me,
public function CheckDates(SDate as Date, EDate as Date) as integer
Dim msg as String
msg = ""
if (SDate > EDate) then
msg = "ERROR. Start Date must fall before the End Date."
else
if datePart("yyyy", SDate) <> datePart("yyyy", EDate) then
msg = "ERROR. Dates must be within the same calendar year."
end if
end if
if msg <> "" then
err.raise (6)
return -1
end if
end function
NOTE: I remvoed System.Web.HttpContext.Current.Response.
Hope the infomration above helps.
Thanks,
Eileen
Free Windows Admin Tool Kit Click here and download it now
June 26th, 2011 8:26am