Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I pass multiple parameter values to Reporting Services Report c#

Posted on 2009-07-12
5
Medium Priority
?
2,087 Views
Last Modified: 2012-08-13
I have the code below to programatically render a report in Reporting Services 2008 and pass the parameters needed.

One of the parameters can accept multiple values. How can I pass these from the C# code? I've tried passing Comma seperated values (1, 2, 2 etc), but is throws an exception.

The parameters are selected from an SQL database in varchar(50) format.
if (_parameters.Length > 0)
                {
                  parameters[0] = new BECScheduler.rsExecService.ParameterValue();
                  parameters[0].Label = "";
                  parameters[0].Name  = "SDate"; 
                  parameters[0].Value = sDate;
                  parameters[1] = new BECScheduler.rsExecService.ParameterValue();
                  parameters[1].Label = "";
                  parameters[1].Name = "EDate";
                  parameters[1].Value = eDate;
                  parameters[2] = new BECScheduler.rsExecService.ParameterValue();
                  parameters[2].Label = "";
                  parameters[2].Name = "TLInstance1";
                  parameters[2].Value = TLInstance1;
                  parameters[3] = new BECScheduler.rsExecService.ParameterValue();
                  parameters[3].Label = "";
                  parameters[3].Name = "TLInstance2";
                  parameters[3].Value = TLInstance2; 
                }

Open in new window

0
Comment
Question by:wint100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 15

Expert Comment

by:jinal
ID: 24836669
Hello ,

You can set Values property.


This linkj give you more detail.
http://msdn.microsoft.com/en-us/library/ms251764(VS.80).aspx
0
 
LVL 15

Expert Comment

by:rob_farley
ID: 24837620
How did you try passing in the list?

Like this?

(and for the record - I haven't had to do this before, but I'm just thinking about how SSRS understands multivalue parameters)

parameters[3] = new BECScheduler.rsExecService.ParameterValue();
parameters[3].Label = "";
parameters[3].Name = "TLInstance2";
parameters[3].Value = "1, 2, 3";

0
 
LVL 1

Author Comment

by:wint100
ID: 24837627
Yes thats right, with comma then a space before the next value.
0
 
LVL 15

Accepted Solution

by:
rob_farley earned 2000 total points
ID: 24837650
Actually, do this... populate an array of strings (called yourarray here), and then make the parameter using a different constructor, like this:

ReportParameter[] parameters = new ReportParameter[3];
....
parameters[3] = new ReportParameter("TLInstance2", yourarray);

Hope this helps...

Rob


0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question