惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MyScale Blog
MyScale Blog
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
M
MIT News - Artificial intelligence
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园_首页
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
L
LangChain Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
L
LINUX DO - 热门话题
Project Zero
Project Zero
罗磊的独立博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
Spread Privacy
Spread Privacy
S
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
J
Java Code Geeks
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - Franky
T
Threat Research - Cisco Blogs
D
Docker
Hugging Face - Blog
Hugging Face - Blog
S
Securelist
Google DeepMind News
Google DeepMind News
T
The Exploit Database - CXSecurity.com
L
Lohrmann on Cybersecurity
月光博客
月光博客
V
Vulnerabilities – Threatpost
NISL@THU
NISL@THU
V
Visual Studio Blog
AWS News Blog
AWS News Blog
I
Intezer
T
The Blog of Author Tim Ferriss
P
Privacy International News Feed
T
Tor Project blog
F
Full Disclosure
P
Proofpoint News Feed
SecWiki News
SecWiki News
H
Heimdal Security Blog
Help Net Security
Help Net Security
The Hacker News
The Hacker News

博客园 - iCeSnaker

[转载]两个未公开的ACCESS方法的使用技巧 Microsoft AntiSpyware Beta1 发布了,贴几张图片上来 大型组图:微软总部印象 两个桌面主题 [讨论] 制作博客园年刊 用C#实现生成PDF文档 C# Delegate 简介 单元测试的基本方法 小软件项目开发的管理 C#中为DataGrid添加下拉列表框 用C#读取XML文档 什么是需求? 呐喊 -- 希望博客圆一直是世外桃源 将sql server中的数据倒入Excel(c#) 在.net中轻松掌握Windows窗体间的数据交互(三) 在.net中轻松掌握Windows窗体间的数据交互(二) 在.net中轻松掌握Windows窗体间的数据交互(一) C# 编码规范和编程好习惯 C#实现的基本算法
Microsoft SQL Reporting Services – Running a Report from the Command Line
iCeSnaker · 2005-01-07 · via 博客园 - iCeSnaker

Posted on 2005-01-07 13:29  iCeSnaker  阅读(1769)  评论()    收藏  举报

Microsoft SQL Reporting Services – Running a Report from the Command Line Author: 
Published: 1/6/2005

 

Introduction

I recently ran into a need to run a report in SQL reporting services from the command line. The Report took four (4) input parameters and I had to export it to Microsoft® Excel and save it to disk. I had to rummage through the product documentation and the Microsoft® SQL Reporting newsgroup to get this right. For running reports from the command line, SQL Reporting services provide a utility called “rs utility”.

The rs Utility

The rs utility is a script host that processes script you provide in an input file. You can define scripts to administer a report server, copy report server database content to another database, publish reports, and so forth. The script must be written in Microsoft Visual Basic® .NET code, and stored in a Unicode or UTF-8 text file with a .rss file extension. You cannot debug scripts with the rs utility. To debug a script, run the code from within Visual Studio.

To run the tool, you must be a local administrator on the computer that has the report server instance you are running the script against. There are some script samples provided with the Reporting Services installation and the samples are located in the following directory in your Reporting Services installation: <Reporting Services>\Samples\Scripts

“Run Report” Script

The following script is meant to run the report by passing it parameters and saving the output to Excel. Out of the four (4) parameters required by the report, the values for three of the parameters are hard-coded in the script file. The fourth parameter expects a value to be provided at runtime during the running of the script.

' File: RunReport.rss 

Dim format as string = "Excel"
Dim fileName 
as String = "C:\Export2.xls"
Dim reportPath 
as String = "/SalesDashboard/Overview"

Public Sub Main()

    
' Prepare Render arguments
    Dim historyID as string = Nothing
    Dim deviceInfo 
as string = Nothing
    Dim showHide 
as string = Nothing
    Dim results() 
as Byte
    Dim encoding 
as string
    Dim mimeType 
as string = "ms-excel"
    Dim warnings() AS Warning 
= Nothing
    Dim reportHistoryParameters() As ParameterValue 
= Nothing
    Dim streamIDs() 
as string = Nothing
    rs.Credentials 
= System.Net.CredentialCache.DefaultCredentials

    
' Report Parameters 
    Dim parameters(3) As ParameterValue
    parameters(
0= New ParameterValue()
    parameters(
0).Name = "SalesType"
    parameters(
0).Value = "Auto"
    parameters(
1= New ParameterValue()
    parameters(
1).Name = "Country"
    parameters(
1).Value = "Japan"
    parameters(
2= New ParameterValue()
    parameters(
2).Name = "Year"
    parameters(
2).Value = "2004"
    parameters(
3= New ParameterValue()
    parameters(
3).Name = "Month"
    parameters(
3).Value = MonthParameter
    results 
= rs.Render(reportPath, format, _
        Nothing, Nothing, parameters, _
        Nothing, Nothing, encoding, mimeType, _
        reportHistoryParameters, warnings, streamIDs)

    
' Open a file stream and write out the report 
    Dim stream As FileStream = File.OpenWrite(fileName)
    stream.Write(results, 
0, results.Length)
    stream.Close()

End Sub

'End of script 


To run the script, and pass the fourth parameter (MonthParameter) at runtime, issue the following command at the command prompt –

rs –i RunReport.rss –s http://localhost/reportserver -v MonthParameter=”9” 

The -v flag above declares a global variable called MonthParameter and initializes it with the value “9”. This global variable is used in the script to set value to the Month parameter as parameters(3).Value = MonthParameter