How to change the data source dynamically using Report Serializer

To change the data source dynamically with the Bold Reports® ReportSerializer, load the report definition, set the connection string of each data source, and save the definition to the report stream in the OnInitReportOptions method. ReportSerializer converts the report to a C# object model, so you can modify the data source connections in code, as in the following example:

    public void OnInitReportOptions(ReportViewerOptions reportOption)
    {
        FileStream inputStream = new FileStream(@"C:\Users\Resources\sales-order-detail.rdl", FileMode.Open, FileAccess.Read);

        BoldReports.RDL.DOM.ReportSerializer serializer = new BoldReports.RDL.DOM.ReportSerializer();
        BoldReports.RDL.DOM.ReportDefinition reportDefinition = serializer.GetReportDefinition(inputStream);
        string connectionString = "Data Source =<instancename> ; Initial Catalog = <database>; User ID = '<username>'; Password = '<password>'";
        foreach (var source in reportDefinition.DataSources)
        {
             source.ConnectionProperties.ConnectString = connectionString;
        }
         MemoryStream reportStream = new MemoryStream();
         serializer.SaveReportDefinition(reportStream , reportDefinition);
         reportStream.Position = 0;
         reportOption.ReportModel.Stream = reportStream;
    }

See also