LoadReportDefinition fails - invalid datasource reference RRS feed

  • Question

  • Hi

    I have a report which I can execute without any problems as a server report , on the server, by specifying the report path. I need to be able to load the report definition dynamically instead

    However when I try to load the report definition dynamically using the LoadReportDefinition function, the report falls over with error "The report server cannot process the report. The datasource connection information has been deleted. (rsInvalidDataSourceReference)." 

    A shared datasource defintiely exists on the server. Code is shown below, can anyone shed light on why this happening and how to fix it?

    Dim serverReport As ServerReport  
    serverReport = ReportViewer1.ServerReport  
    ' Get a reference to the default credentials  
    Dim credentials As System.Net.ICredentials  
    credentials = System.Net.CredentialCache.DefaultCredentials  
    ' Get a reference to the report server credentials  
    Dim rsCredentials As ReportServerCredentials  
    rsCredentials = serverReport.ReportServerCredentials  
    ' Set the credentials for the server report  
    rsCredentials.NetworkCredentials = credentials  
    serverReport.ReportServerUrl = New Uri(gReportingServicesURL)  
    'this works!!!  
    serverReport.ReportPath = "<report path>" 
    Dim reportDefinitionReader As New StringReader(xmlReportDefinition)  
    'this falls over  
    ' Set the report parameters for the report  
    If _parameters IsNot Nothing AndAlso _parameters.Length > 0 Then 
    End If 
    ' Set the processing mode for the ReportViewer to Remote  
    ReportViewer1.ProcessingMode = ProcessingMode.Remote  
    ' Run report  
    Tuesday, November 25, 2008 10:39 AM


  • for anyone searching this issue in the future I worked it out.

    When you run a server report using LoadReportDefinition it automatically defaults to the top level of the report server instance, specified by the ReportServerURL. That means if you have a shared data source reference like I did, you need to explicitly specifiy the path to the shared data source - so if the data source exists in a sub-folder "Data Sources" , make sure the <DataSourceReference> element in the rdl is 

          <DataSourceReference>/Data Sources/DataSourceName</DataSourceReference>

    --> not <DataSourceReference>DataSourceName</DataSourceReference>

    • Marked as answer by GeordieBoy Thursday, November 27, 2008 9:52 AM
    Thursday, November 27, 2008 9:52 AM