Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 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