Quantcast
Channel: SQL Server Reporting Services
Viewing all articles
Browse latest Browse all 1418

RS.EXE - Automate report upload and change report datasource

$
0
0

Hi, I need to automate the deployment of our reports to the report server. I am using rs.exe and I have got it almost working as I need it to. The only part that I am stuck on is being able to change the report datasource once it has been uploaded to the server.

An example;

My report locally refer to a datasource called 'Local_DS'.

'Local_DS' does not exist on my report server in the datasource folder BUT a datasource called 'LIVE_DS' does.

I need to change each reports datasource from 'Local_DS' to now use 'LIVE_DS'.

This is where I am stuck. I have gotten close, I think, but maybe looking at it too hard now and missing the obvious.

Here is what I have got so far;

        rs.Credentials = System.Net.CredentialCache.DefaultCredentials

        Dim item As CatalogItem

        Dim items As CatalogItem()

        Try

            items = rs.ListChildren("/" + ReportFolder, False)

            For Each item In items

                Dim dataSources() As DataSource = rs.GetItemDataSources(item.Path)

                For Each ds As DataSource In dataSources

                    'Set report DataSource references
                    Dim sharedDataSources(0) As DataSource

                    sharedDataSources(0) = GetDataSource(DataSourcePath, item.Name)

                    Dim sharedDataSourceReference0 As New DataSourceReference

                    sharedDataSourceReference0.Reference = DataSourcePath

                    Dim sharedDataSource0 As New DataSource

                    sharedDataSource0.Item = CType(sharedDataSourceReference0, DataSourceDefinitionOrReference)

                    sharedDataSource0.Name = DataSourceName

                    sharedDataSources(0) = sharedDataSource0

                    rs.SetItemDataSources("/Datasource/" + DataSourceName, sharedDataSources)

                    Console.WriteLine("Set " & ds.Name & " datasource for " & item.Path & " report")

                Next

            Next

            Console.WriteLine("Shared data source reference set for reports in the {0} folder.", ReportFolder)

This does not seem to work for me. Can anyone point me to a working example?


Viewing all articles
Browse latest Browse all 1418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>