0
votes

I am trying to pass a variable from my classic asp page to ssrs. When I put in a literal value for the parameter, such as 296, it works fine. But I want to put in a variable that is sent by the URL so that it works in different ways for different people who are logged in. So, instead of a URL that is http://servername.net/reportserver....rs:Command=Render&Agency=296 (for the agency that is number 296) I want to use a variable that I have set to the agency of the person who has logged in. Let's say the variable is pAgency. I have tried Agency=" @pAgency (I set pAgency = to the logged in person's agency) and all sorts of other combinations, and have searched the web, but find no answer for this. I've even tried session variables but, no go. You must be able to do this but...

Thanks for any help you can give. Cheers!

1

1 Answers

0
votes

That is not how a rest URI works to my knowledge. You need to build the string and present it first fully formed, not define a variable on it. You could do somthing in code like (using HTML Form as a base)

In the example below there are four clear things to understand:

A. The 'action' in the form must be the webservice location of a report and do a post to self. (Or you can do an iframe element potentialy but I have not messed with that as much)

B. The 'input' element is text based but you MUST match the id and name to the name of your parameter passing in.

C. The 'select' element gives a user 'option's of save methods to output directly to common types.

D. The 'input' for a type of 'submit' ensure the form will post to itself with the data prescribed.

<!DOCTYPE HTML>
<html>
    <head>
        <title>SSRS Tester</title>
    </head>
    <body>
        <form id="SSRSRender" action="http:// (reportservername)/ReportServer?/(pathtoreport)" method="post" target="_self">
            <H3>Enter some detail for the report to render</H3>
            My Variable 'Test': <input type="text" id="Test" name="Test">
            <br/>
            My outputs:
            <select ID="rs:format" name="rs:format" size=1>
                <option value="HTML4.0">HTML 4</option>
                <option value="IMAGE">Tiff Image</option>
                <option value="PDF">PDF</option>
            </select>
            <br/>
            <input type="submit" value="Render Report">
        </form>
    </body>
</html>

If you want to do more types of input variables to dynamically get SSRS to render as you want outside of the SSRS landing page you need to determine if you want to use:

  1. The service with some front end with scripting like javascript with HTML
  2. Something more easy to control will pre built tools like 'Report Viewer' with ASP.NET or a client application in C# or VB.NET
  3. Create the service proxy yourself in a class library and do the calls in code directly as well as the formatting

Trying to create a rest URI programatically is better done by contacting the service and using built in methods IMHO rather than trying to make a string. It may be a little more of a learning curve but it will help you in the end.