Using rs.exe to deliver reports does not connect to my shared datasource
Following some advice on here, I created a .bat file that uses rs.exe and an rss file to deliver my reports to our Production Report Server. This delivers the reports OK but leaves them detached from the shared Datasource. All my reports use the same shared datasource so if I deploy using Visual Studio, I get a message that the Datasource was not replaced because I didn't specify that option in the deploy. However, when I deliver the report using the batch file and rs.exe, I get a message "The data set 'xxx' refers to the shared data source 'yyyy', which is not publsihed on the report server. Well it is because I can see it there and all my other reports are using it fine. If I try and run the report, it fails because it is not attached to a Datasource. However, I can link that report to that datasource (the one the error message says is not published there) and it then runs fine. If I subsequently redeploy the report using the same .bat file, I get the same error message but now the report runs OK - presumably because I have manually associated it with that Datasource. This is my RSS file: Dim definition As [Byte]() = Nothing Dim warnings As Warning() = Nothing Public Sub Main() Try Dim stream As FileStream = File.OpenRead(sourcePath + "\" + reportName + ".rdl") definition = New [Byte](stream.Length) {} stream.Read(definition, 0, CInt(stream.Length)) warnings = rs.CreateReport(reportName, targetFolder, True, definition, Nothing) If Not (warnings Is Nothing) Then Dim warning As Warning For Each warning In warnings Console.WriteLine(warning.Message) Next warning Else Console.WriteLine("Report: {0} published successfully with no warnings", reportName) End If Catch e As IOException Console.WriteLine(e.Message) End Try End Sub And this is how I invoke rs.exe in my .bat file: SET targetFolder=/Operational SET sourcePath=\\DC1VTSTSV025\D$\Development\INGIS\Reporting\Main\Reports\Customer Care KPIs SET reportName=Policy Release Times rs.exe -i "\\DC1VTSTSV025\D$\Development\INGIS\Reporting\Main\Scripts\Batch Files\INGISRSS.rss" -s http://%INGISSQLServer%/ReportServer -v sourcePATH="%sourcePath%" -v targetFolder="%targetFolder%" -v reportName="%reportName%" SET reportName=App Summary Received Times rs.exe -i "\\DC1VTSTSV025\D$\Development\INGIS\Reporting\Main\Scripts\Batch Files\INGISRSS.rss" -s http://%INGISSQLServer%/ReportServer -v sourcePATH="%sourcePath%" -v targetFolder="%targetFolder%" -v reportName="%reportName%" Can anyone tell me what I'm missing?
September 17th, 2010 7:50am

Hi Nick, In SQL Server Reporting Services, a report uses DataSourceReference to refer to a shared data source. The DataSourceReference includes the path and the name of the shared datasource. If the path defined in the report is different with the path of the shared datasource in the Report Server, the report will fail to run. In this caes, the issue may be due to the datasource in the report server has the different path with the report definition. To solve the issue, we need to add the referenece explicitly using the following code: Public Sub SetDataSource() rs.Credentials = System.Net.CredentialCache.DefaultCredentials Try Dim reference As New DataSourceReference() reference.Reference = "/Data Sources/AdventureWorks2008_2" Dim source As New DataSource() source.Item = reference source.Name = "AdventureWorks2008" Dim sources As DataSource() = New DataSource(0) {} sources(0) = source rs.SetItemDataSources("/AdventureWorks 2008 Sample Reports 2/Company Sales 2008", sources) Catch e As IOException Console.WriteLine(e.Message) End Try End Sub If you have any more questions, please feel free to ask. Thanks, Jin Chen Jin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
September 20th, 2010 1:21pm

Hi Jin Thanks. That sounds like the exact reason why my Data Source can't be found after I deploy the report. However, I confess that I didn't really understand what I was doing when I created the rss file. I was merely cribbing from an example I found on the web. I don't understand how I would incorporate that additional code in my RSS file. I think I recognise the code as Visual Basic or a scripting language based on it and can understand some of what it does but I'm at a loss to know how I would call that subroutine from my main code (or even if that's how I should do it). Also, I'm assuming that your first string literal is the folder on my server where the Datasource resides and the last part is the actual Datasource name. I'm not sure what the source.Name = "Adventureworks2008" refers to. I think that the last literal is referring to a folder on my Report Server and a report name that would be joined to the source. I guess that means I could use my environment variables to substitute for those values, too? Some of my reports have 2 datasources (for extracting data from 2 different databases). How would I handle those situations with your example code? Thanks again. Nick
September 22nd, 2010 5:53am

Hi Nick, If the datasource was deployed to the same folder we have defined in the report. It will work. However, if the data source was deployed to another folder, we need to recreate the reference. Thanks, Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
October 11th, 2010 6:24am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics