none
Passing Multi-Valued Parameters to a WebService

    Dotaz

  • Hi,

    I am creating a report in which I have to pass a list of item ids or names to a method in a web service. Is there anyway to do this or do I have to stick to passing single values to my service methods?

    Thanks in advance,

    Vahid

    22. března 2012 9:33

Odpovědi

  • I found a way around this:

    Instead of passing a multi-valued parameter to the web service, I pass a single comma seperated string parameter which I construct by looping through the multi-valued one! 

    multi valued paameters have in fact the type: System.Object[] . So I created a new parameter of Type string and used expressions to set its value by calling a function which creates a comma seperated string from the multi valued parameter: 

    =Code.ReportHelper.CreateCSVString(Fields!MultiValuedParameter.Value)

    ReportHelper is a helper class I have written in C# and referenced in the ssrs project:

     public string CreateCSVString(System.Object[] parameters)
            {
                StringBuilder result = new StringBuilder();
                for (int i = 0; i < parameters.Length; i++)
                    if (i == 0)
                        result.Append(parameters[i].ToString());
                    else
                        result.Append(" ," +parameters[i].ToString());
                return result.ToString();
            }

    Thanks,

    Vahid



    • Označen jako odpověď vmesri 22. března 2012 15:04
    • Upravený vmesri 22. března 2012 15:07
    22. března 2012 15:04

Všechny reakce

  • So you want to pass multi-valued parameters to report or web service?

    Thanks, Rahul Techie.

    22. března 2012 12:10
  • Hello,

    Follow the links below. It will help you.

    http://stackoverflow.com/questions/1261433/passing-values-for-multi-value-parameter-in-ssrs-query-string

    http://stackoverflow.com/questions/1916309/pass-multiple-parameters-to-jquery-ajax-call

    22. března 2012 13:31
  • I want to pass a multi-valued parameter to a web service from SSRS
    22. března 2012 14:53
  • I found a way around this:

    Instead of passing a multi-valued parameter to the web service, I pass a single comma seperated string parameter which I construct by looping through the multi-valued one! 

    multi valued paameters have in fact the type: System.Object[] . So I created a new parameter of Type string and used expressions to set its value by calling a function which creates a comma seperated string from the multi valued parameter: 

    =Code.ReportHelper.CreateCSVString(Fields!MultiValuedParameter.Value)

    ReportHelper is a helper class I have written in C# and referenced in the ssrs project:

     public string CreateCSVString(System.Object[] parameters)
            {
                StringBuilder result = new StringBuilder();
                for (int i = 0; i < parameters.Length; i++)
                    if (i == 0)
                        result.Append(parameters[i].ToString());
                    else
                        result.Append(" ," +parameters[i].ToString());
                return result.ToString();
            }

    Thanks,

    Vahid



    • Označen jako odpověď vmesri 22. března 2012 15:04
    • Upravený vmesri 22. března 2012 15:07
    22. března 2012 15:04