all groups > sql server reporting services > august 2006 >
You're in the

sql server reporting services

group:

How do I set a set a report parameter value using the webform RVC?


How do I set a set a report parameter value using the webform RVC? Chris G.
8/10/2006 2:22:01 PM
sql server reporting services: SSRS 2005

We have an ASP.NET application which permits the user to switch between
different databases depending on their permissions. As soon as the user
chooses a new database, the application shows data from the new database.

I am using the Report Viewer Control to allow the users to run remote reports.

I need the reports to also switch to accessing the new database once it is
selected. I know how I can use a hidden report parameter and a database
connection expression to switch the reports to different databases.

But, how do I set the report accessed by the RVC to use the new database
connection parameter value after the user has switched to a new database?

Can I use something like:

RVC.ServerReport.ReportServerUrl = ...
RVC.ServerReport.ReportPath = reportPath = ...

and then use

RVC.ServerReport.SetParameters()
RVC.ServerReport.Refresh()

to set the hidden parameter which will specify the database to connect to?

--
RE: How do I set a set a report parameter value using the webform RVC? stcheng NO[at]SPAM online.microsoft.com
8/11/2006 12:00:00 AM
Hello Chris,

Yes, you're right, you can use the ReportViewer Control's "ServerReport"
property to dynamically customize the report server url and report server
path if you want to display different report according to different user
inputs or other conditions.

And the ServerReport.SetParameters method can help programmtically specify
parameter values for the report. Be careful tha the SetParameters methdo
accept collection which contains "ReportParameter" class instances. And
this class can only contains string value based "name/value" paramter pair.
So if you have any complex object parameter(such as Datetime), you need to
convert it to string first. For example:

==========================
protected void Page_Load(object sender, EventArgs e)
{
string reportpath = Request.QueryString["rptpath"];

if (!string.IsNullOrEmpty(reportpath))
{


ReportViewer1.ServerReport.ReportPath = reportpath;

ReportParameter[] pms = new ReportParameter[1];

DateTime date = DateTime.Parse("2005-3-10");
pms[0] = new ReportParameter("Raw_Date_Param",
date.ToShortDateString() );


ReportViewer1.ServerReport.SetParameters(pms);

ReportViewer1.ServerReport.Refresh();
}
}
============================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.



RE: How do I set a set a report parameter value using the webform Chris G.
8/15/2006 2:07:02 PM
Steven,

When SetParameters() is used, do values have to be provided for all
parameters? Or is it possible to just populate certain parameters?

--
Chris, SSSI


[quoted text, click to view]
RE: How do I set a set a report parameter value using the webform stcheng NO[at]SPAM online.microsoft.com
8/16/2006 2:44:06 AM
Hi Chris,

As for the "SetParameters" method of ServerReport class, it accept a
collection (normally a Array) of ReportParameter class instances. Also,
the ReportParameter class contains a name/value string pair, so you do not
need to provide values for every parameter of a certain server report. You
can just create ReportParameter instances for the certain named parameters
you want to supply. And the server report will use a empty value or default
value for those non-supplied parameters.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
RE: How do I set a set a report parameter value using the webform lukezhan NO[at]SPAM online.microsoft.com
8/21/2006 12:00:00 AM
Hello Chris,

How are you doing on this issue. Does Steven's reply and suggestion helps
you some? If there is still anything we can help, please feel free to post
in the newsgroup.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,

Luke Zhang

Microsoft Online Community Support
This posting is provided "AS IS" with no warranties, and confers no rights.


AddThis Social Bookmark Button