Hi Borg239,
Tristan is right. I have tested the script, it only work while the data sources are in the same folder of the reports.
To store the data sources in other folders, we need to SetItemDataSources as Tristan described.
Below is a sample code for your reference:
Public Sub SetDataSource()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Try
Dim reference As New DataSourceReference()
reference.Reference = "/Data Sources/PDataSet"
Dim source As New DataSource()
source.Item = reference
'The source name must be the data source name we used in the report.
source.Name = "PDataSet"
Dim sources As DataSource() = New DataSource(0) {}
sources(0) = source
rs.SetItemDataSources("/Reports/<report name>", 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