0
votes

I try to pass to a SSRS report, from the C# code multiple arrays of integer

var rsExec = new ReportExecutionServiceSoapClient(binding, new EndpointAddress(config.ReportExecutionUrl));

ParameterValue[] reportParam = new ParameterValue[] {
    new ParameterValue { Name = "pCityId", Value = cityId.ToString() },
    new ParameterValue { Name = "pDepartmentIds", Value = string.Join(",", departmentIds) },
    new ParameterValue { Name = "pBuildingIds", Value = string.Join(",", buidingIds) }
};

await rsExec.SetExecutionParametersAsync(null, null, reportParam, "en-us");

enter image description here

as the Value type of ParameterValue is "string", it seems I have no choice but passing a CSV as parameter to the report.

Then, in the report I can use data type as integer, and say that I am passing "multiple values", but how to do it from the C# code?

enter image description here

PS. Related to that question

1
Multiple values would be an array in c# : new ParameterValue { Name = "pBuildingIds", Value = new int[] {1,2,3,4} }jdweng
@jdweng thanks, as mentioned, Value is of String typeserge
The type in SSRS has to match the c#. The picture showed integer (not string).jdweng
the picture is from SSRS side. The string is on the C# side...serge
I think that what you need to do is send a ParameterValue for each value in the departmentIds collection, all with the same parameter name ("pDepartmentIds"). So, if there was 3 department IDs to send, the reportParam array should contain 3 ParameterValue objects, all with the name "pDepartmentIds", one for each department ID. Similar for buildingIds.R. Richards

1 Answers

2
votes

To send parameters where the Allow multiple values option is selected, you need to send a new ParameterValue object for each value that is going to be consumed by the report, all with the same Name.

In the case described above, you need to send a ParameterValue for each value in the departmentIds collection, all with the same parameter name ("pDepartmentIds").

So, if there was 3 department IDs to send, the reportParam array should contain 3 ParameterValue objects, all with the name "pDepartmentIds", one for each department ID.

ParameterValue[] reportParam = new ParameterValue[] {
    new ParameterValue { Name = "pCityId", Value = cityId.ToString() },
    new ParameterValue { Name = "pDepartmentIds", Value = "1" },
    new ParameterValue { Name = "pDepartmentIds", Value = "2" },
    new ParameterValue { Name = "pDepartmentIds", Value = "3" },
    ...
};

Do something similar for buildingIds.