I have two stored procedures, one used to get data for the main report and other for Sub report.I have send parameter to main report
using ReportDocument. But I am not aware how to send parameters to SubReport.
I tried many diff ways using the reportdocument's setparameter method which also takes subreport name as argument.But it didn't.
Can anyone let me know how to send params to Subreport.
prathap.3567
Member
1 Points
9 Posts
Sending parameters to Subreport in Crystal Reports
Feb 23, 2013 01:58 AM|LINK
Hi,
I have two stored procedures, one used to get data for the main report and other for Sub report.I have send parameter to main report
using ReportDocument. But I am not aware how to send parameters to SubReport.
I tried many diff ways using the reportdocument's setparameter method which also takes subreport name as argument.But it didn't.
Can anyone let me know how to send params to Subreport.
Need code snippet in C#
aaa_78600
Participant
942 Points
198 Posts
Re: Sending parameters to Subreport in Crystal Reports
Feb 23, 2013 02:17 AM|LINK
http://www.codeproject.com/Questions/470908/Crystal-report-SubReport-Link-parameters-error
http://www.codeproject.com/Questions/408633/how-to-set-sub-report-parameter-using-coding
http://www.codeproject.com/Questions/525229/SubplusreportplusParameterplusnotplusset
prathap.3567
Member
1 Points
9 Posts
Re: Sending parameters to Subreport in Crystal Reports
Feb 23, 2013 02:49 AM|LINK
Hi,
I have tried the below code
try { AccountsPayableMaster objAPM = new AccountsPayableMaster(); QuotationReport obj = new QuotationReport(); objReportDocument.Load(Application.StartupPath + @"\rptQuotationReport.rpt"); obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_SalesOrderReport;1"); // Main Report SP obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_GetBatchReportDetails;1"); /// SubReport SP objReportDocument.SetParameterValue("@QuoteID", ValQuoteID); objReportDocument.Subreports["Sub.rpt"].SetParameterValue("@QuoteBatchID", ValQuoteID); // Throws Error //objReportDocument.SetParameterValue("@QuoteBatchID", ValQuoteID,"Sub.rpt"); objReportDocument.SetParameterValue("Type", Type); string[] Print = objAPM.GetPrintDetails(); SetPrintParameters(objReportDocument, Print); obj.Show(); objReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, FilePath); obj.crysQuotationReport.ReportSource = objReportDocument; // Number++; } catch (Exception ex) { MessageBox.Show(ex.Message); }Above code throws an error object reference not set to an instance where the Subreport parameter is being Set.
I have tried to set the the SubReport Parameter by using below methods
1) objReportDocument.Subreports["Sub.rpt"].SetParameterValue("@QuoteBatchID", ValQuoteID); // Throws Error 2) objReportDocument.SetParameterValue("@QuoteBatchID", ValQuoteID,"Sub.rpt");
3) objReportDocument.Subreports["Sub"].SetParameterValue("@QuoteBatchID", ValQuoteID); // Throws Error 4) objReportDocument.SetParameterValue("@QuoteBatchID", ValQuoteID,"Sub");
I dont understand where am i going wrong.