Trying to re-use the same report... bad results
Posted: Wed Jul 03, 2013 10:52 am
I have one report that should launched many times changing just one parameter, and I'm trying to NOT recompile each time the MRT (to save memory).
1. The first time the report has been requested I load in a private variable:
2. after the Compile() I inject the Datasource parameter:
3. finally I render it and assign to report viewer
When my code call the same report I'm trying to avoid re-compiling the MRT doing the following:
but the report always shows the old values... how to manage this?
If this is the wrong way, how can I re-use the same report without re-compiling it each time (avoiding memory leaks and improving performance)?
thanks in advance
[Stimulsoft Reports .NET 2012.2]
1. The first time the report has been requested I load in a private variable:
Code: Select all
string reportToLaunch = Path.Combine(@"c:\path", "report.mrt");
_CostificationMOReport = new StiReport();
_CostificationMOReport.Load(reportToLaunch);
_CostificationMOReport.Compile();
Code: Select all
_CostificationMOReport.DataSources["MyDS"].Parameters.Clear();
_CostificationMOReport.CompiledReport.DataSources["MyDS"].Parameters.Clear();
_CostificationMOReport.DataSources["MyDS"].Parameters.Add(new Stimulsoft.Report.Dictionary.StiDataParameter("@pID", "1", 22, 50));
_CostificationMOReport.CompiledReport.DataSources["MyDS"].Parameters.Add(new Stimulsoft.Report.Dictionary.StiDataParameter("@pID", "1", 22, 50));
Code: Select all
_CostificationMOReport.Render(false);
_viewer.Report = _CostificationMOReport;
Code: Select all
//clear pages
_viewer.Report =null;
_CostificationMOReport.CompiledReport.RenderedPages.Clear();
//clear old parameters
_CostificationMOReport.DataSources["MyDS"].Parameters.Clear();
_CostificationMOReport.CompiledReport.DataSources["MyDS"].Parameters.Clear();
//inject new parameters
_CostificationMOReport.DataSources["MyDS"].Parameters.Add(new Stimulsoft.Report.Dictionary.StiDataParameter("@pID", "2", 22, 50));
_CostificationMOReport.CompiledReport.DataSources["MyDS"].Parameters.Add(new Stimulsoft.Report.Dictionary.StiDataParameter("@pID", "2", 22, 50));
//render
_CostificationMOReport.Render(false);
//re-assign to report viewer
_viewer.Report = _CostificationMOReport;
//I tried even this, but doesn't work
// _CostificationMOReport.ViewerControl = _viewer;
// _CostificationMOReport.Show();
// _CostiticationMOReport.InvokeRefreshViewer();
If this is the wrong way, how can I re-use the same report without re-compiling it each time (avoiding memory leaks and improving performance)?
thanks in advance
[Stimulsoft Reports .NET 2012.2]