http://msdn.microsoft.com/zh-cn/library/ms160854(v=sql.90).aspx

脚本示例 (Reporting Services)

SQL Server 2005
此主题尚未评级 - 评价此主题

以下示例提供了使用 Microsoft Visual Basic .NET 为 Reporting Services 编写的脚本。脚本示例通常是针对单个功能或技术问题的,是基于任务的。您可以使用脚本文件和 Reporting Services SOAP API 进行报表服务器上的大多数管理操作。

重要提示:
这些示例仅供教学使用。这些不是针对生产环境设计的,也没有在生产环境中进行测试。对于这些示例,Microsoft 不提供相关的技术支持。

下表对示例脚本进行了说明。

文件 说明

AddItemSecurity.rss

示范如何使用脚本在报表服务器命名空间中设置项安全性策略。

CancelRunningJobs.rss

示范一个示例管理脚本,该脚本可取消报表服务器上运行的作业。

ConfigureSystemProperties.rss

示范一个可以用来设置系统级属性和报表服务器属性的脚本。

PublishSampleReports.rss

示范一个可以将示例报表发布到报表服务器的脚本。

要求


在运行示例脚本之前,必须要满足以下条件:

  • 必须使用 Reporting Services 安装程序或单独的示例安装程序,先将示例报表和脚本文件安装到硬盘上。
  • 您必须拥有在安装了报表服务器实例的计算机上运行 rs 实用工具的权限。
  • 您必须拥有报表服务器的访问权限,才能使用脚本对它进行访问。
  • 您必须对要访问的报表服务器的根文件夹具有相应的权限。有关权限和用户角色的详细信息,请参阅管理 Reporting Services 的权限和安全性。

脚本文件的位置


将示例安装到默认安装目录时,默认情况下,脚本示例位于 C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Script Samples。

注意:
如果尚未安装示例,请参阅安装示例。

运行示例脚本


您可以在 Reporting Services 脚本环境中运行示例脚本。

运行此示例


  1. Open a command prompt: On the Start menu, click Run, type cmd in the text box, and then click OK.

  2. 导航到包含示例脚本的目录。例如,如果示例脚本安装在默认目录中,请在命令提示符下键入以下内容:

    复制
    cd C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Script Samples
    

  3. 在命令提示符下,输入以下内容,以查看 rs 实用工具的可用命令提示选项列表:

    复制
    rs -?
    

    注意:
    如果收到消息,通知您 rs 不是已知命令或批处理文件,则需要将 rs.exe 的位置添加到 Windows 环境变量 PATH 中。
  4. 在命令提示符下,键入相应的命令以运行该示例脚本文件。例如,将给定的服务器 URL 替换为所访问的报表服务器时,若要运行 PublishSampleReports.rss,请键入以下命令:

    复制
    rs -i PublishSampleReports.rss -s http://myserver/reportserver
    

修改脚本文件


您可以使用文本编辑器打开所有 .rss 文件。

请参阅


任务

编译和运行代码示例
SQL Server Reporting Services 示例

其他资源

Scripting with the rs Utility and the Web Service
应用程序示例 (Reporting Services)
Accessing the SOAP API

帮助和信息

获取 SQL Server 2005 帮助

=========

'=============================================================================
'  File:      PublishSampleReports.rss
'
'  Summary:  Demonstrates a script that can be used with RS.exe to
'       publish the sample reports that ship with Reporting Services.
'
'---------------------------------------------------------------------
' This file is part of Microsoft SQL Server Code Samples.
'
'  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.
'=============================================================================
'
' 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 杤 switch, and then
' publishes the sample reports that ship with Reporting Services to a report server.
' Depending on the location of your sample reports, you may need to modify the
' value of the filePath variable, which references the path to your sample reports.
'
' 1.2 Script Variables
'
' Variables that are passed on the command line with the -v switch:
'
' (a) parentFolder - corresponds to the folder that the script creates and uses
'     to contain your published reports
'
' 1.3 Sample Command Lines
'
'
' 1.3.1 Use the script to publish the sample reports to an AdventureWorks Sample Reports folder.
'
'       rs -i PublishSampleReports.rss -s http://myserver/reportserver
'
Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim parentFolder As String = "AdventureWorks Sample Reports"
Dim parentPath As String = "/" + parentFolder
Dim filePath As String = "C:\Program Files\Microsoft SQL Server\100\Samples\Reporting Services\Report Samples\AdventureWorks Sample Reports\"
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
'Create the parent folder
Try
rs.CreateFolder(parentFolder, "/", Nothing)
Console.WriteLine("Parent folder {0} created successfully", parentFolder)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
'Create the AdventureWorks shared data source
CreateSampleDataSource("AdventureWorks", "SQL", "data source=(local);initial catalog=AdventureWorks")
CreateSampleDataSource("AdventureWorksDW", "OLEDB-MD", _
"data source=localhost;initial catalog=Adventure Works DW")
'Publish the sample reports
PublishReport("Company Sales")
PublishReport("Employee Sales Summary")
PublishReport("Product Catalog")
PublishReport("Product Line Sales")
PublishReport("Sales Order Detail")
PublishReport("Territory Sales Drilldown")
End Sub
Public Sub CreateSampleDataSource(name As String, extension As String, connectionString As String)
'Define the data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
definition.ConnectString = connectionString
definition.Enabled = True
definition.EnabledSpecified = True
definition.Extension = extension
definition.ImpersonateUser = False
definition.ImpersonateUserSpecified = True
'Use the default prompt string.
definition.Prompt = Nothing
definition.WindowsCredentials = False
Try
rs.CreateDataSource(name, parentPath, False, definition, Nothing)
Console.WriteLine("Data source {0} created successfully", name)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub
Public Sub PublishReport(ByVal reportName As String)
Try
Dim stream As FileStream = File.OpenRead(filePath + reportName + ".rdl")
definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()
Catch e As IOException
Console.WriteLine(e.Message)
End Try
Try
warnings = rs.CreateReport(reportName, parentPath, False, definition, Nothing)
If Not (warnings Is Nothing) Then
Dim warning As Warning
For Each warning In warnings
Console.WriteLine(warning.Message)
Next warning
Else
Console.WriteLine("Report: {0} published successfully with no warnings", reportName)
End If
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub

脚本示例 (Reporting Services)Microsoft Visual Basic .NET相关推荐

  1. VBS是基于Visual Basic的脚本语言,全称是:Microsoft Visual Basic Script Edition

    VBS是基于Visual Basic的脚本语言.VBS的全称是:Microsoft Visual Basic Script Edition.(微软公司可视化BASIC脚本版). 其语言类似Visual ...

  2. Microsoft Visual Basic for Applications 编译错误:更新 Declare 语句

    Microsoft Visual Basic for Applications 编译错误:更新 Declare 语句 Microsoft Visual Basic for Applications 编 ...

  3. Microsoft Visual Basic/C++ Redistributable v0.56.0 开源VC运行库合集

    前言 Microsoft Visual C++ Redistributable(简称MSVC,VB/VC,系统运行库)是Windows操作系统应用程序的基础类型库组件.此版VC++运行库组件合集轻量版 ...

  4. microsoft visual basic保存时错误429_win10更新失败错误8000FFF的解决小技巧

    一位深度之家官网的朋友在win10 2004系统中windows update检测更新升级补丁时,遇到了8000FFF的错误提示问题,出现这样的提示说明注册表键值中有错误信息所引起的无法检查更新.接下 ...

  5. 解决打开word时显示microsoft visual basic运行时错误没有注册类的问题

    新安装office2019,出现这个问题,需要点击多次调试才能进去软件,用了百度上面的各种方法,最后,看了大佬的连接解决了 先找到C:\Users\你自己的用户\AppData\Roaming\Mic ...

  6. 打开word时显示microsoft visual basic运行时错误没有注册类怎么解决?

    先找到C:\Users\你自己的用户\AppData\Roaming\Microsoft\Word\STARTUP文件夹下的模板文件NEWebWordAddin.dotm,删除. 第一步执行完之后没解 ...

  7. [电脑问题1]Microsoft Visual Basic运行时错误‘-2147221164’:没有注册类

    问题描述 解决方法: 删除 C:\用户\用户名\AppData\Roaming\Microsoft\Word\STARTUP 中的.dotm文件.

  8. [转载] 启用和禁用 Reporting Services 的客户端打印和导出文件格式

    启用和禁用 Reporting Services 的导出文件格式: 您可以修改rsreportserver.config,对于SQL Server 2005,它位于C:\Program Files\M ...

  9. 充分利用 SQL Server Reporting Services 图表

    最近在查SSRS的一些文章,看到MSDN在有一篇不错的文章,许多图表设置都有说明,共享给大家.. 其中有说明在SSRS中如果去写条件表达写和报表属性中的"自定义代码",文章相对比较 ...

最新文章

  1. 动态添加跨行表格_学会这2招,轻松搞定数据透视表动态更新,效率猛增一倍...
  2. java单链表例子_写一个java链表的例子?随便举例说一下。
  3. 国内开源软件镜像网站大全
  4. 这个C怎么了?求大佬指教
  5. arcgis属性表选择两个条件_ARCGIS关联属性表(转)
  6. 学习 ASP.NET MVC (第五回)理论篇
  7. 学计算机买小米air可以么,Mi 小米 Air13.3 笔记本电脑 三个月使用体验
  8. Leetcode五大常用算法
  9. python培训学堂怎么样_如何评价开智学堂开设的课程?
  10. C++ 求指定函数的定积分问题
  11. 工业物联网设计普遍存在哪些问题?
  12. 使用GLAD加载OpenGL的库
  13. python植物大战僵尸辅助_Python自学入门,如何制作植物大战僵尸
  14. xubuntu language support
  15. windows 7 iso镜像刻录到U盘后选择安装的版本
  16. epoll 为什么用红黑树?
  17. 在Windows 7 Media Center中收听本地FM广播
  18. 如何做出好看的三维平面地图?
  19. HTML5 实现扫描识别二维码 生成二维码
  20. 腾讯地图JS API制作专题图

热门文章

  1. 下列叙述正确的是( )
  2. 排序算法 —— 插入排序
  3. 大数据WEB阶段(十三)JSP(一)JSP基础、JSP指令详解、四大域九大隐式对象总结
  4. 【Qt】Qt中QJsonValue类
  5. 【Linux】一步一步学Linux——indent命令(262)
  6. 【Linux基础】kiickstart无人值守安装
  7. python就业前景如何_2020年Python就业前景如何?就业岗位多不多?薪资高不高?...
  8. 每天一道LeetCode-----将单词数组分成多行,每行长度相同,单词之间用空格分隔,要求空格尽量均匀分布
  9. Buuoj reverse1
  10. beanpostprocessor与@autowired的关系