Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Automating Smart-Client Report Deployments : Page 3

Building reports is often easier than getting them into users' hands and making sure they're used correctly, but now you can use the SQL Server Reporting Services Web service to automate deployment and control execution of reports.


advertisement
The CreateDataSource Method
The CreateDataSource method creates a data source in the specified folder with the specified name and connection string, first checking whether the named data source already exists. If it does exist, the method deletes and then replaces it.

The code checks for an existing data source with the specified name in the same way as in the CreateFolder example shown earlier. After establishing that the named data source does not already exist, it creates a DataSourceDefinition object, and calls the CreateDataSource method to create the Data Source.

dsNewDataSource = _ New ReportServer.DataSourceDefinition With dsNewDataSource .ConnectString = DataSourceConnectionString .CredentialRetrieval = _ CredentialRetrievalEnum.Integrated .Enabled = True .EnabledSpecified = True .Extension = "SQL" .ImpersonateUser = False .ImpersonateUserSpecified = True .WindowsCredentials = True End With ReportServer.CreateDataSource( _ DataSourceName, "/" & ReportServerFolder, True, dsNewDataSource, CreateStandardProperties)

The DeployReport Method
The DeployReport method deploys a report to the report server using the CreateReport Web method. You pass the contents of the report (.rdl) file to the CreateReport Web method as an array of bytes.

Public Sub DeployReport(ByVal ReportFolder As String, ByVal ReportFilename As String) Dim strmReportFile As System.io.FileStream Dim definition() As Byte Dim warnings() As ReportServer.Warning = Nothing Dim warning As ReportServer.Warning Dim strWarning As String Dim strReportName As String Dim strName as String strName = _ System.IO.Path.GetFileNameWithoutExtension( _ ReportFilename) strmReportFile = _ System.IO.File.OpenRead(ReportFilename) ReDim definition(strmReportFile.Length) strmReportFile.Read _ (definition, 0, strmReportFile.Length) strmReportFile.Close() warnings = _ mobjReportServer.CreateReport( _ strName, _ "/" & ReportFolder, _ True, definition, CreateStandardProperties) End Sub

Table 1 shows the arguments to the CreateReport method.

Table 1. CreateReport Arguments: The table contains a list of arguments to the CreateReport method along with a description of each.
Argument Description
Report The name of the report.
Folder The folder you want to create the report in. The folder name must start with the "/" character (use "/" to specify the root folder).
Overwrite Specifies whether to automatically overwrite a report with the same name, if it exists.
Definition The report definition (.rdl) file as an array of bytes.
Properties An array of Property objects representing user-defined properties and values. You can pass Nothing (or null) if you don't have any user-defined properties to add.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date