Solved

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

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

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 14

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now