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

Zansheen 26 Reputation points
2021-02-25T18:32:22.9+00:00

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.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,659 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xingyu Zhao-MSFT 5,361 Reputation points
    2021-02-26T02:03:06.407+00:00

    Hi @Zansheen ,
    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful