Script sample (Reporting Services) Microsoft Visual Basic. net__.net

Source: Internet
Author: User
Tags soap microsoft sql server

http://msdn.microsoft.com/zh-cn/library/ms160854 (v=sql.90). aspx Script sample (Reporting Services) SQL Server This topic has not been rated-evaluate this topic

The following example provides scripts written for Reporting Services using Microsoft Visual Basic. NET. The scripting examples are usually for a single feature or technical problem, and are task-based. You can use script files and the Reporting Services SOAP APIs for most administrative operations on a report server.

Important NOTE:
These examples are for teaching use only. These are not designed for production environments and are not tested in a production environment. For these examples, Microsoft does not provide relevant technical support.

The following table describes the sample scripts.

file Description

Additemsecurity.rss

Demonstrates how to use scripts to set item security policies in the report server namespace.

Cancelrunningjobs.rss

Demonstrates an example management script that cancels jobs running on a report server.

Configuresystemproperties.rss

Demonstrates a script that can be used to set system-level properties and Report server properties.

Publishsamplereports.rss

Demonstrates a script that can publish a sample report to a report server.

Requirements

Before you can run the sample script, you must meet the following criteria: You must install the sample reports and script files to your hard disk by using the Reporting Services Installer or a separate sample Setup program.
You must have permission to run the Rs utility on the computer where the report server instance is installed.
You must have access to the report server before you can access it using a script.
You must have appropriate permissions on the root folder of the report server that you want to access. For more information about permissions and user roles, see Managing Permissions and Security for Reporting Services.
Location of script files

When you install the sample to the default installation directory, the script example is located in C:\Program Files\Microsoft SQL server\90\samples\reporting Services\script samples by default.

Attention:
If the example is not already installed, see Installing the sample.

Run the sample script

You can run sample scripts in the Reporting Services scripting environment. Run this example

Open a command prompt:on the Start menu, click Run, type cmd in the text box, and then click C5>ok.

Navigate to the directory that contains the sample script. For example, if the sample script is installed in the default directory, at the command prompt, type the following: copy

CD C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\script Samples

At the command prompt, enter the following to view a list of available command prompt options for the Rs utility: Replication

RS-?
Attention:
If you receive a message informing you that RS is not a known command or batch file, you will need to add the Rs.exe location to the Windows environment variable PATH.

At the command prompt, type the appropriate command to run the sample script file. For example, to run Publishsamplereports.rss when you replace a given server URL with a report server that you access, type the following command: Copy

Rs-i publishsamplereports.rss-s Http://myserver/reportserver
modifying script files

You can use a text editor to open all. rss files. See tasks compiling and running code samples
SQL Server Reporting Services sample
Other Resources Scripting with the RS Utility and the Web Service
Application sample (Reporting Services)
Accessing the SOAP API

Help and information get SQL Server 2005 Help

=========

' ============================================================================= ' File:PublishSampleReports.rss ' Summary:demonstrates a script that can be used with RS.exe to ' publish the sample reports the
ing 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.
Materials for detailed information regarding Microsoft code samples. ' This CODE and information ARE provided ' as is ' without WARRANTY to any ' KIND, either expressed or implied, including
BUT not LIMITED to the "implied warranties of merchantability and/or for A ' FITNESS particular. ' ============================================================================= ' 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 Operat Ions on a specified server.  The script creates a folder ' you specify as a command-prompt variable using the 杤 switch, and then ' publishes '
Sample reports that ship and Reporting Services to a server. ' Depending on the location of your sample reports, with may need to modify the ' value of the FilePath variable, which re
Ferences the path to your sample reports. ' 1.2 Script Variables ' Variables that are passed on the command line with THE-V switch: ' (a) Parentfolder-cor Responds to the "the script" creates and uses ' to contain your published ' reports
NES ' 1.3.1 Use the script to publish the sample reports to a 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 = "Adventurewor KS 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 sou Rce Createsampledatasource ("AdventureWorks", "SQL", "Data source= (local); initial catalog=adventureworks") Createsa

    Mpledatasource ("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 ("P Roduct Line Sales] Publishreport ("Sales order Detail") Publishreport ("Territory Sales Drilldown") End Sub Publi C 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 are nothing) Then Di M warning as warning for each warning in warnings Console.WriteLine (warning. Message) Next warning Else Console.WriteLine ("A: {0} published successfully with no" 
 Warnings ", ReportName) end If Catch e as Exception Console.WriteLine (e.message) End Try End Sub

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.