Solved

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

Posted on 2009-07-12
5
2,080 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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