|
|
Question : Semi Urgent - Reporting Services 2005 - pass multi-value parameter to function in code behind
|
|
In reporting services 2005, how would I call a function in the code behind, and successfully pass a multivalue parameter? If i have a parameter defined for state that is multi-value, and i want to do something like this the command text window:
=Code.BuildSQLQuery(Parameters!StateParameter.Value)
where the parameter "StateParameter" is a multi-value dropdown...and then in the code window have something like this:
Public Shared Function BuildSQLQuery(ByVal strState as string) As String Dim sql As String = "" sql = " SELECT * from SOME_TABLE WHERE state_id IN " + strState BuildSQLQuery = sql End Function
When I set the state parameter to multivalue, i get a generic error - when i un-check multivalue, it passed the value to the function just fine....any ideas?
|
Answer : Semi Urgent - Reporting Services 2005 - pass multi-value parameter to function in code behind
|
|
Hello, That's the syntax how to extract a list of values from a mutli-value parameter:
=Join( Parameters!MyParam.Value, ", " )
You may want to modify your query as well:
"... WHERE state_id IN (" & strState & ")"
As you're using VB.NET syntax, it's better use & to concatinate rather than +
Why would you do this kind of thing though? I mean create a sql query in the embedded function? You can have this kind of query in your dataset and pass a multi-valued parameter EASILY there, just like that:
SELECT * from SOME_TABLE WHERE state_id IN ( @MyParam )
Regards, Yurich
|
|
|
|
|