SSRS 2005, RS command utility to export report with parameters?
Hi, I have a reporting service report on my localhost reporting service (http://localhost/reportserver) in sub folder "/Country/All Division/Sub Division/My report.rdl" with 4 parameters which I need toenter toview report.(1) Can I have SSRS 2005 sample RSS file to render report into EXCEL location at "C:\Temp\My report extract.xls"?(2) Also pls can you give me RS command line to execute that RSS file on my localhost pls. (like rs -i C:\tem[\my extract.rss......)?Pls can you post rss file and rs command to execute my above query. (pls don't post any website reference URL). Any sample code pls. Thanksyou.
September 23rd, 2009 7:31am

Hi Superdec, The RS script utility uses the Reporting Services web services to access the report server. So, we can use the utility to export reports to a specified folder. Here is a sample for your reference: '============================================================================= ' File: ExportReport.rss ' ' Summary: Demonstrates a script that can be used with RS.exe to ' export reports to a specified folder. ' '--------------------------------------------------------------------- ' Author: Jin Chen ' ' Copyright (C) Microsoft Corporation. All rights reserved. ' ' This source code is intended only as a supplement to Microsoft ' Development Tools and/or on-line documentation. See these other ' materials for detailed information regarding Microsoft code samples. ' ' THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY ' KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE ' IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A ' PARTICULAR PURPOSE. ' ' Microsoft MSDN Forum Support ' '============================================================================= ' ' 1.0 Documentation ' ' Read the following in order to familiarize yourself with the sample script. ' ' 1.1 Overview ' ' This sample script uses a script file (.rss) and the script environment to run ' Web service operations on a specified report server. The script creates a folder ' that you specify as a command-prompt variable using the -v switch, and then ' export the sample reports that ship with Reporting Services to a specified physical folder. ' Depending on the location of your exported reports, you may need to modify the ' value of the filePath variable, which references the path to your exported reports. ' ' 1.2 Script Variables ' ' Variables that are passed on the command line with the -v switch: ' ' (a) reportPath - corresponds to the report that is being to exported. ' (b) vFullPathOfOutputFile - corresponds to the folder that is used to store the exported file. ' ' 1.3 Sample Command Lines ' ' ' 1.3.1 Use the script to publish the sample reports to an AdventureWorks Sample Reports folder. ' ' rs -e Exec2005 -s http://localhost/reportserver -i "C:\Program Files\Microso 'ft SQL Server\90\Samples\Reporting Services\Script Samples\ExportReport.rss" -v 'vFullPathOfOutputFile="c:\exported file name.pdf" -v vReportPath="/ReportSamples/P1" -v 'vFormat="PDF" ' Dim reportPath As String = vReportPath Dim format As String = vFormat Dim fullPathOfOutputFile = vFullPathOfOutputFile Public Sub Main() ' Authenticate to the Web service using Windows credentials rs.Credentials = System.Net.CredentialCache.DefaultCredentials Dim report As Byte() = Nothing Dim deviceinfo As String = Nothing Dim parameters As ParameterValue() = Nothing Dim historyID As String = Nothing Dim credentials As DataSourceCredentials() = Nothing Dim showHideToggle As String = Nothing Dim extension As [String] = String.Empty Dim encoding As [String] = String.Empty Dim mimeType As [String] = String.Empty Dim warnings As Warning() = Nothing Dim reportHistoryParameters As ParameterValue() = Nothing Dim streamIDs As String() = Nothing Dim execInfo As New ExecutionInfo() Dim execHeader As New ExecutionHeader() rs.ExecutionHeaderValue = execHeader execInfo = rs.LoadReport(reportpath, historyID) Try report = rs.Render("PDF", deviceinfo, extension, mimeType, encoding, warnings, streamIDs) Dim fs As New FileStream(fullPathOfOutputFile, FileMode.Create) fs.Write(report, 0, report.Length) fs.Close() Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub If there is anything unclear, please let me know. Thanks, Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2009 10:06am

Thanks Jin. But I have report with two paramter which I need to supply to run report (Datetime & String). Any idea how to pass parameter?
October 1st, 2009 5:10am

Hi Superdec,For passing parameters to a report, we can use the following code:' Prepare report parameter. Dim parameters(2) As ParameterValue parameters(0) = New ParameterValue() parameters(0).Name = "EmpID" parameters(0).Value = "288" parameters(1) = New ParameterValue() parameters(1).Name = "ReportMonth" parameters(1).Value = "6" ' June parameters(2) = New ParameterValue() parameters(2).Name = "ReportYear" parameters(2).Value = "2004"rs.SetExecutionParameters(parameters, "en-us")I would suggest you reading the following article to get more information about "Render" method: feel free to ask if you have any more questions.Thanks,Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
October 1st, 2009 9:36am

Jin:I used the code that you provided to help me get started on an automation project that is going to save me a lot of time.So - thanks!- Simon
December 15th, 2009 7:37pm

Hi In the above example, you have passed parameters by specifying their names and values. Now I have stored the paramenter name and values for each report in an SQL table. So how do I pass them into this rss script, without specifying the values and names in the rss script. I hope I have been clear. Any help would be appreciated. Thanks
Free Windows Admin Tool Kit Click here and download it now
March 2nd, 2012 5:22pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics