Introduction
In Part 1, we discussed that in development environment, we deploy reports by simply clicking “Deploy” in BIDS, but this won’t work in production. To deploy reports in production, we need to write an SSRS script, which is actually a piece of VB.NET code executing against SSRS web service.
A typical report consists of the report definition (the .rdl
file) that references one or more data sources. And this is where things get tricky.
Deploying Data Sources
- Code to deploy a data source
- Code to deploy data source and report
You create a data source using a call to rs.CreateDataSource() method. Unfortunately, this method does not accept .rds
files that BIDS uses to store data source information. Instead, it wants a DataSourceDefinition object. This means that one must parse the .rds
file and convert it to a DataSourceDefinition
instance. Here’s a piece of code that does that. It is geared for datasources with integrated credentials, if you use other kind of credentials, you’ll need to make relevant modifications.
Dim doc As System.Xml.XmlDocument = New System.Xml.XmlDocument
doc.Load(rdsPath)
Dim dataSource As DataSourceDefinition = New DataSourceDefinition
dataSource.ConnectString = doc.SelectSingleNode_
("/RptDataSource/ConnectionProperties/ConnectString/text()").Value
dataSource.Extension = doc.SelectSingleNode("/RptDataSource/ConnectionProperties/Extension/text()").Value
dataSource.CredentialRetrieval = CredentialRetrievalEnum.Integrated
dataSource.Enabled = True
dataSource.EnabledSpecified = True
Dim name As String
name = doc.SelectSingleNode("/RptDataSource/Name/text()").Value
Dim overwrite As Boolean = false
rs.CreateDataSource(name, "/Data Sources", overwrite, dataSource, Nothing)
This was easy, wasn’t it? The full version of the code with logging and error handling can be found here.
But data sources are only one half of the story. In Part 3, we will discuss how to deploy reports.
CodeProject
This article was originally posted at
http://www.ikriv.com/blog?p=1248