0
votes

I have an Active Reports 13 report defined using the rdlx format. The report also contains a number of sub-reports.

When defined in the report designer the data source is set to some test data, however, when the report is embedded in a WPF application we wish to update the location of the database pragmatically.

We have been able to update the data source for the main report, but it is not clear (to us!) how to update the data source for the sub-reports.

string report = _reportPath;
// checked the report file exists ...
if (File.Exists(report))
{
    // create and setup the data source
    // create an empty page report
    GrapeCity.ActiveReports.PageReport def = new GrapeCity.ActiveReports.PageReport();

    //load the report layout
    def.Load(new System.IO.FileInfo(report));

    //setup the dataset
    GrapeCity.ActiveReports.PageReportModel.DataSource myDataSource = def.Report.DataSources[0];

    def.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";

    def.Report.DataSources[0].ConnectionProperties.ConnectString = @"RunData.mdb;provider=Microsoft.Jet.OLEDB.4.0;";


    // loop through subreports and set the location of the run data database
    // ????

    reportViewer.LoadDocument(def.Document);
}

Does anyone have some pointers to how we should be writing the code at "????" above to also update the subreports?

1

1 Answers

0
votes

This is done in an event on the report document LocateDataSource

Also, please refer to this sample to see how the LocateDataSource is being used: DataSet DataSource. You can access the sample application by downloading a trial of ActiveReports 13 here.

Best,

GrapeCity Support Team