Reputation: 13
I have a crystal report that includes two sub reports and it causes missing parameter values error on the call of ExportToDisk. It is working just fine with subreport[0], and the error comes after subreport[1] is added.
Am I doing wrong on using a subreport[1]? Any advise would be greatly appreciated.
Thanks,
using (ReportClass rptH = new ReportClass())
{
rptH.FileName = "Report.rpt";
rptH.Load();
List<SampleDetails> aDetails = new List<SampleDetails> ();
aDetails = GetADetailsData();
rptH.SetDataSource(aDetails);
List<SampleHeader> aHeader = new List<SampleHeader>();
aHeader = GetAHeaderData();
rptH.Subreports[0].SetDataSource(aHeader);
List<SampleData> aFooter = new List<SampleData> ();
aFooter = GetAFooterData();
rptH.Subreports[1].SetDataSource(aFooter);
sPath = "Output.pdf");
FileStream fs1 = new FileStream(sPath, FileMode.OpenOrCreate, FileAccess.Write);
fs1.Close();
rptH.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, sPath);
}
Upvotes: 1
Views: 3508
Reputation: 11
If you're loading a sub-report from a dataset, you need to load the parameters before setting any parameters in the main report. Example:
reportSOA report = new reportSOA();
report.Subreports["reportSOA_Details.rpt"].Database.Tables["Transactions"].SetDataSource(ListOfTransactions);
report.SetParameterValue("CompanyName", reportCompanyName);
If you flip line 2 and line 3, you will get this error. Hope this saves your time
Upvotes: 0
Reputation: 2111
rptH.Subreports[1].SetParameterValue("@your parameter namme", parametervalue);
try this.
Upvotes: 2