PASS Parameters directly to the URL in SSRS

Source: Internet
Author: User
Passing parameters and other options directly through a URL in Reporting Services
Written By: Rob Fisch
Problem
Reporting Services has export great built in features, but accessing them externally can be tricky. Suppose you wanted to pass a variable directly within a URL? Wouldn't it be great if you cocould provide a URL from a website or email that renders a report directly in Excel? Do you need to display a report (perhaps a chart) while hiding the reporting toolbar? Let's take a look at these items as well as a few others and how you can use parameters in your URL to change the report behavior.

Solution
Follow these steps to discover various solutions to these and other issues.

Solution setup:

For this demo we will be using the same sample database I used in my tip on drill down techniques, (Follow the instructions in the "Sample Data" box .)

Create a new report using the VISIBILITY_EXAMPLE_TABLE as a datasource. Use the following SQL statement as the report's first dataset:

Select productcode, productname, productcolor, quantityavailable, suppliername, supplierregion
From visibility_example_table

From the Layout tab, add the six fields to a new data table.

Add a second dataset to the report and call it AvailableColors.

Enter this for the SQL statement of the new dataset:

Select distinct productcolor
From visibility_example_table
Order by productcolor

Return to the first dataset and add the following line:

WHERE ProductColor = @ ProdColor

The entered dataset shocould look like:

Select productcode, productname, productcolor, quantityavailable, suppliername, supplierregion
From visibility_example_table
Where productcolor = @ prodcolor

From the Report menu, select Report Parameters. in Available values, select From query, and change the Dataset to AvailableColors, and select ProductColor in both the Value and Label fields. leave the Default to Null. the entire Report Parameter screen shoshould like this below:

Now save and publish the report to your Reporting Services web server. Access your report from the web server using the Report Server (not the Report Manager ).

Your browser screen shoshould look like this before clicking the report. (The name of my server is Zorro. henceforth, replace "Zorro" with the machine name of your SQL server .) the name of my report is called "zPass_Params_with_HTML ". you can name your report whatever you like.

When you first run the report, you shocould be prompted for a parameter:

Just to try it out, select a parameter and run the report.

As long as everything works we're re ready to have some fun ....

Passing the parameter entirely through HTML

Start over with your browser at the ProdColor prompt. Instead of choosing the color from the dropdown, add the following at the end of the URL:

& Amp; ProdColor = Green.

It shoshould look like this:

Do not click the View Report button, but instead, click the go button in the browser. you shoshould get the same results as if you used the dropdown within the report. this shoshould give you the idea that you can programmatically pass parameters from another program or web site.

Controlling Report Options

So you want to hide the parameter bar by default, try adding this to the end of the URL:

& Rc: Parameters = false

The full URL shoshould look like this:

Http: // zorro/ReportServer /? % 2 fEdgewoodLab % 2fzPass_Params_with_HTML & rs: Command = Render & ProdColor = Green & rc: Parameters = false

How about hiding the toolbar? Add this to the end of the URL:

& Rc: Toolbar = false

Controlling Report Format (Opening Excel or Acrobat by default)

If you haven't already done it, let's roll back to the original URL.

Http: // zorro/ReportServer /? % 2 fEdgewoodLab % 2fzPass_Params_with_HTML & rs: Command = Render
(Remember to replace "Zorro" with the name of your server and use whatever you named your report .)

Now add the following on the end of the URL:

& Rs: Format = Excel

Try this at the end:

& Rs: Format = PDF

As you can see, there are using different options for presenting your report directly from a URL. this introduction shoshould give you a foundation to read further on this topic. there is extensive documentation in Books Online.

Next Steps
  • Try combining the & rc: Toolbar = false tip with a series of charts that you can put together in a dashboard on a web site. this can be done from a series of iframes on a standard website or from Sharepoint in Page Viewer web parts.
  • Check books online or Microsoft for more detailed documentation on passing parameters in a URL and other report options.
  • Take a look at these other reporting services tips.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.