Solved

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

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

In this article I will describe the Backup & Restore 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.
In this article I will describe the Copy Database Wizard 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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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