question

Zansheen-3703 avatar image
0 Votes"
Zansheen-3703 asked Zansheen-3703 commented

How to pass a report parameter with multiple values from vb.net

I am currently using Visual Studio 2013 and I am writing a service that will allow someone to choose report settings and pass them into the SSRS 2016 report.
I am coding this is VB.net.

The issue I am having is one report parameter has been setup to allow multiple values.
The multi value parameter works fine from SSRS.
Once I try to pass in a string from VB.net though it errors out if it has more than one value in it.
If you pass in "P1" for instance it works fine but, if you pass in "P1, P2" you get the following error. This report requires a default or user-defined value for the report parameter '<ParameterName>'. To run or subscribe to this report, you must provide a parameter value.

I have looked up several forum posts about split it in to a list of strings or to an array and neither have worked.
I get an error saying you cannot convert the "ListOfStrings" to a ParameterValue or something Similar

If you need more info just let me know :).
Any Help would be appreciated. Thanks.

dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

XingyuZhao-MSFT avatar image
0 Votes"
XingyuZhao-MSFT answered Zansheen-3703 commented

Hi @Zansheen-3703 ,
In order to pass multi value parameter to SSRS, you can try the following code.

     Dim rptParams As List(Of ReportParameter) = New List(Of ReportParameter)()
     Dim param As ReportParameter = New ReportParameter("ParamName")
     Dim values As String() = New String() {"P1", "P2"}
     param.Values.AddRange(values)
     rptParams.Add(param)
     Me.ReportViewer1.ServerReport.SetParameters(rptParams)

Hope it could be helpful.
Besides, if I have any misunderstanding, please provide the code you've tried.

Best Regards,
Xingyu Zhao


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I will try it out now and let you know. Thanks for the Resonse!

0 Votes 0 ·

I have a dataset I am pulling from and then set and pass those variables to the function individually via a For Each Loop.
The function below is in a function in a module not a form or anything. This runs as a service being triggered at specific time intervals setup with settings stored in a database. Right now it is every 30 seconds
I know the case statement needs to be changed up a bit to allow for my dynamic variable settings but I am currently trying to get this to run without error first :).
When I try to add in the Values in the code you show it says Values do not exist in the reference. Please seethe attached pictures/code.
Any other ideas? Am I missing something? Thanks

72575-code.txt72601-errors.jpg72576-reference.jpg72577-reference2.jpg


0 Votes 0 ·
code.txt (3.8 KiB)
errors.jpg (44.0 KiB)
reference.jpg (16.4 KiB)
reference2.jpg (23.7 KiB)

Hi @Zansheen-3703 ,
Also take a look at the following reference:
SSRS: How to set Multiple Values on ParameterValue object?
You can convert the code to visual basic.


0 Votes 0 ·

That worked! Thanks I was able to use that C# code in SSRS: How to set Multiple Values on ParameterValue object? to the setup a dynamic loop to add on to the static ParametersValues that were set first.


0 Votes 0 ·