1
votes

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);
        }
2
Do you get a parameter prompt before the report is exported? - aMazing
I didn't realized as it did not prompt. Thanks, - Jimmy
Parameter issue is cleared by changing the sub report. Now ExportToDisk throws an error "The system cannot find the path specified." when aFooter.count = 0 I have set the sub report with "Suppress Blank Subreport" and also "Suppress Blank Section" in the section of main report that includes the sub report. However, it still crashes on the ExportToDisk. Can anyone tell me how to prevent this error? Thanks a lot! - Jimmy

2 Answers

2
votes
rptH.Subreports[1].SetParameterValue("@your parameter namme", parametervalue);

try this.

0
votes

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