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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 小小小程序员

转载 gridview在绑定显示的各种格式 - 小小小程序员 - 博客园 转 ASP.NET 2.0中OWC生成柱状图和饼状图的源代码 - 小小小程序员 同一个ASP站点UTF-8和GB2312的两个子站点乱码的解决方法 - 小小小程序员 转 ASP.NET 页面事件执行顺序 转 用 Javascript 验证表单(form)中的单选(radio)值 - 小小小程序员 转 .net里如何判断中文字符长度 转CSDN Sybase PowerDesigner专区 转 ASP.net中的Server.UrlEncode函数和ASP中的Server.URLEncode函数返回的值竟然不一样!!!! DIV实现下拉菜单 转 .NET 2.0 SqlDependency快速上手指南 使用XMLHTTP 获取服务器数据,实现无刷新效果 转 SQL Server 2005中设置Reporting Services发布web报表的匿名访问 - 小小小程序员 div 属性 OBJECTPROPERTY函数使用 转 数字金额大小写转换之存储过程 转 PowerDesigner教程系列 - 小小小程序员 [转载]ASP.NET 格式化字符串 转 VS.NE类、变量、文件命名规范 - 小小小程序员 转 MVC在Web系统中的模式与应用
转 SqlServer 2005 报表批量自动部署
小小小程序员 · 2007-09-07 · via 博客园 - 小小小程序员

当我们需要把设计好的报表发布到Web服务器上时,如果用VS2005只需要 右击报表工程,单击Deploy就可轻松搞定,如果不用VS2005发布,该怎么办?

解决办法有2种。
1.引用 sqlserver2005 的web服务。根据他提供的方法发布报表
2.用sqlserver2005 的rs.exe 命名发布。

我这里介绍的是根据 rs.exe这个命令来自动发布报表的。脚本已经写好,直接Copy 稍微的改动一下即可!

1.现看看rs.exe参数 都代表什么

RUN --CMD
C:\Documents and Settings\junmy>rs /?
Microsoft (R) Reporting Services RS
版本 
9.00.1399.00 x86
根据指定的报表服务器执行脚本文件内容。
RS -i 输入文件 -s serverURL 
[-u 用户名] [-p 密码]
   
[-l 超时] [-b] [-e 端点] [-v var=value] [-t]

        -i  输入文件    要执行的脚本文件
        -s  serverURL   执行脚本
                        所依据的 URL (包括服务器和 vroot)。
        -u  用户名      用于登录到服务器中的用户名。
        -p  密码        用于登录到服务器中的密码。
        -e  端点        要与脚本一起使用的 Web 服务端点。
                        选项为:
                        Exec2005 - ReportExecution2005 端点
                        Mgmt2005 - ReportService2005 端点
                        Mgmt2000 - (不推荐使用) ReportService 端点
        -l  超时        连接到服务器之前
                        超时的秒数。默认值为 

60 秒,0 表示
                        无限长的超时。
        -b              作为批进行运行,且如果命令失败则回滚
        -v  var
=value   传递给脚本的变量和值
        -t  跟踪        在错误消息中包含跟踪信息

C:\Documents and Settings\junmy>

 

2.拷贝下面脚本保存deployReport.rss 相应路径根据自己的情况改动.

Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
'目录名
Dim datasourceFolderName As String = "Data Sources"
Dim datasourceFolderPath As String = "/" + datasourceFolderName
'报表目录名  所有发布的报表放在此目录
Dim reportsFolderName As String = "testDeployReports"
Dim reportsFolderPath As String = "/" + reportsFolderName
'设计好的报表 存放的路径
Dim filePath As String = "D:\Project\Reports\"
'链接字符串
Dim connectionString As String = "Data Source=localhost;Initial Catalog=DataBaseName;Connect Timeout=120"Public Sub Main()
    rs.Credentials 
= System.Net.CredentialCache.DefaultCredentials
    
'创建报表目录
    CreateReportFolder(reportsFolderName)
    
'创建DataSource 目录
    CreateReportFolder(datasourceFolderName)
    
'创建数据源
    CreateDataSource(datasourceFolderPath)'部署报表
    DeployRepors(filePath)
End Sub'创建目录
Public Sub CreateReportFolder(ByVal reportFolder As String)Try
        
'Create Reports Folder
        rs.CreateFolder(reportFolder,"/",Nothing)

                Console.WriteLine(

"Parent Folder Created:{0}",reportFolder)
    
Catch e As Exception
        Console.WriteLine(e.Message)
    
End TryEnd Sub'部署报表
Public Sub DeployRepors(ByVal filePath As String)Dim tempFileAry As String()
    
Dim reportFilePath as String
    tempFileAry 
= Directory.GetFiles(filepath)
    
For Each reportFilePath In tempFileAry
        
Dim fileName As String
        fileName 
= reportFilePath.Substring(reportFilePath.LastIndexOf("\"+ 1)
        
Dim fileSuffix As String
        fileSuffix 
= fileName.Substring(fileName.LastIndexOf("."+ 1)
        
Select Case fileSuffix
            
Case "rdl","png"
                PublishReport(fileName,fileSuffix)
        
End Select
    
NextEnd Sub
'******************************************************************
'
*****           创建数据源                           **************
'
*******************************************************************
Public Sub CreateDataSource(ByVal sourceFolder As String)Dim name As String = "DetechtionCompany"
   
'Define the data source definition.
    Dim definition As New DataSourceDefinition()
    
Dim dSource As New DataSource()

        dsource.Item

=definition

        definition.CredentialRetrieval 

= CredentialRetrievalEnum.Integrated
    definition.ConnectString 
=connectionString
    definition.Enabled 
= True
    definition.EnabledSpecified 
= True
    definition.Extension 
= "SQL"
    definition.ImpersonateUser 
= False
    definition.ImpersonateUserSpecified 
= True
    
'Use the default prompt string.
    definition.Prompt = Nothing
    definition.WindowsCredentials 
= true

        dsource.Name

=datasourceFolderPathTry

                rs.CreateDataSource(name, sourceFolder, 

true, definition, Nothing)
            Console.WriteLine(
"Created DataSource:{0}",name)
    
Catch e As Exception
        Console.WriteLine(e.Message)
    
End TryEnd Sub'******************************************************
'
******* 发布报表 *********
'
*******************************************************

Public Sub PublishReport(ByVal reportName As String,ByVal fileSuffix As String)TryDim stream As FileStream = File.OpenRead(filePath + reportName)
        definition
= New [Byte](stream.Length) {}
        stream.Read(definition, 
0CInt(stream.Length))
        stream.Close()
    
Catch e As IOException
        Console.WriteLine(e.Message)
    
End TryTry
      
'**********************   parentPath
      If(fileSuffix="rdl"Then
        warnings 
= rs.CreateReport(reportName,reportsFolderPath, true, definition, Nothing)
         SetReportDataSourceRef(reportName)
Else If(fileSuffix="png"Then
                rs.CreateResource(reportName,reportsFolderPath,
true,definition,"png",Nothing
      
End If
        
If Not (warnings Is NothingThen
            
Dim warning As Warning
            
For Each warning In warnings
                Console.WriteLine(warning.Message)
            
Next warningElse
            Console.WriteLine(
"Report: {0} published successfully with no warnings", reportName)
        
End IfCatch e As Exception
        Console.WriteLine(e.Message)
    
End Try
End Sub'************************************************************************
'
************* 设置报表数据源      **************************************
'
************************************************************************
Public Sub SetReportDataSourceRef(ByVal reportName As String)
Try
      
Dim reference As DataSourceReference = New DataSourceReference
      
Dim ds As DataSource = New DataSource
      reference.Reference
=datasourceFolderPath+"/DetechtionCompany"
       
Dim dsArray As DataSource()=rs.GetItemDataSources(reportsFolderPath+"/"+reportName)

             ds

=dsArray(0)
       ds.Item 
= CType(reference, DataSourceReference)
      rs.SetItemDataSources(reportsFolderPath
+"/"+reportName,dsArray)Catch _exception As Exception
     Console.WriteLine(_exception)
 
End Try
End Sub

3. 新建deploy.dat 批处理文件 运行上面脚本。用到刚刚说的 rs.exe命名 (相应参数上面已经给出)
deploy.bat 内容

rs -i deploy.rss -s http://192.168.0.88/ReportServer -u userName -p password

 双击运行deploy.bat 报表将自动发布到http://192.168.0.88/ReportServer 服务器上。。
有一个小问题,每次部署后数据源都无法获取用户名和密码。不知道各位有方法没有