0

Here's the scenario: I have many different report files (*.rdl) and the user is able to select one from a web interface. This, in turn, loads a Report Viewer control (as an ASPX control).

My *.rdl files contain both Data Sources and Datasets in the definition (I checked the XML in Notepad just to be sure). The data source is an Oracle Stored Procedure. The report runs just fine if I run it inside Report Builder 3.

What I don't understand is how I can load the report file into the Report Viewer at runtime, and have it automatically use the Data Sources and Datasets that are defined inside the report definition.

try
{
    Viewer.LocalReport.ReportPath = myLocalRDLPath; // Exists and is readable
    var reader = new StringReader(File.ReadAllText(myLocalRDLPath));
    Viewer.LocalReport.LoadReportDefinition(reader);
}
catch(Exception ex)
{
    throw new Exception("Unable to open report definition file from server.", ex);
}

if (Viewer.LocalReport.DataSources.Count > 0)
{
    // Never hits, DataSources is always empty, but
    // a Data Source and a Dataset exist in the .rdl file.
}
qJake
  • 16,821
  • 17
  • 83
  • 135

1 Answers1

0

If you are using .RDL files, you need to use the Viewer.ServerReport. It will use the data sources in the report definition, and there is no need to explicitly set data sources.

The Viewer.LocalReport is for .RDLC files, where setting data sources are set manually in code, as shown in your code sample.

Cam Bruce
  • 5,632
  • 19
  • 34
  • Yeah, I figured that out (see my comment), now I'm facing a new problem, so I posted a new question: http://stackoverflow.com/questions/17621346/how-can-i-execute-an-rdl-report-with-a-report-viewer-control-and-without-an-ssr – qJake Jul 12 '13 at 18:09