开发者

Throw error on parameter validation fail in Reporting Servies 2008

开发者 https://www.devze.com 2023-03-28 04:51 出处:网络
I\'m trying to validate user input on a text parameter using a VB function. I created a hidden text parameter whose default value is the expression =CODE.CheckParameter1(Parameters!Parameter1.Value).

I'm trying to validate user input on a text parameter using a VB function. I created a hidden text parameter whose default value is the expression =CODE.CheckParameter1(Parameters!Parameter1.Value).

This is the specified function:

Function CheckParameter1(Parameter1 as String) as Integer
    If (Not IsNumeric(Parameter1))  Then
        MsgBox("Please enter in a numeric value for Parameter 1", 16, "Validation Error")
        Err.Raise(6,"Please enter in a numeric value for Parameter 1")
    End If
End Function

What I want is for the report to t开发者_运维问答hrow an error message if the input is non-numeric. It catches the error properly, but it doesn't show my custom error message nor does it pop up an MsgBox.

How can I achieve this?


You won't be able to perform parameter validation like this in a straight Reporting Services solution. You can set the parameter to be an integer or a float and use the parameter checking that SSRS provides. Otherwise, you'll need to wrap the SSRS reports in a page (or app) of your own which gathers the parameters.

Msgbox is not supported in SSRS: it is a web application, running through a browser, and it can't popup a message.

An alternative is that you could have a conditionally displayed text box on the report itself that informed the user that some of the parameters were incorrect. This would still require the user to click the "View Report" button before getting the error.

0

精彩评论

暂无评论...
验证码 换一张
取 消