如何将参数发送到Crystal Reports中的子报表 [英] How to send parameters to Subreport in Crystal Reports
问题描述
使用VS 2008。
我有两个存储过程,一个用于获取主报表的数据,另一个用于子报表,两个SP使用相同的参数
I have two stored procedures, one used to get data for the main report and other for Sub report and both the SP's use the same parameter QuoteID.
我使用ReportDocument向主报表发送参数。但我不知道如何发送参数到SubReport。
I have send parameter to main report using ReportDocument. But I am not aware how to send parameters to SubReport.
我尝试了许多diff方法使用reportdocument的setparameter方法,也将子报表名称作为参数。但它没有。
I tried many diff ways using the reportdocument's setparameter method which also takes subreport name as argument.But it didn't.
下面是我使用的代码
string Type = gvQuotationDetails.Rows[QuoteIndex].Cells["Type"].EditedFormattedValue.ToString();
FilePath = ConfigurationManager.AppSettings["EMP_IMG_PATH"].ToString() + "\\" + ValQuoteID.ToString() + ".pdf";
DeleteExistingFile(FilePath);
try
{
AccountsPayableMaster objAPM = new AccountsPayableMaster();
QuotationReport obj = new QuotationReport();
objReportDocument.Load(Application.StartupPath + @"\rptQuotationReport.rpt");
obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_SalesOrderReport;1");
obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_GetBatchReportDetails;1");
obj.crysQuotationReport.ReportSource = objReportDocument;
objReportDocument.SetParameterValue("@QuoteID", ValQuoteID);
objReportDocument.SetParameterValue("Type", Type);
//objReportDocument.Subreports[Application.StartupPath + @"\BatchSubReport.rpt"].SetParameterValue("@QuoteID", ValQuoteID);
//objReportDocument.Subreports["BatchReport.rpt"].SetParameterValue("@QuoteID", ValQuoteID);
string[] Print = objAPM.GetPrintDetails();
SetPrintParameters(objReportDocument, Print);
obj.Show();
objReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, FilePath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
向Subreport发送参数
Sending parameter to Subreport
//objReportDocument.Subreports[Application.StartupPath + @"\BatchSubReport.rpt"].SetParameterValue("@QuoteID", ValQuoteID);
//objReportDocument.Subreports["BatchReport.rpt"].SetParameterValue("@QuoteID", ValQuoteID);
////objReportDocument.SetParameterValue("@QuoteID", ValQuoteID,"BatchReport.rpt);
$ b $ 没有工作。 1] [SD_SalesOrderReport; 1]
main SP和 [SD_GetBatchReportDetails; b
子报表SP。
nothing worked.I have already wasted two days on this. [SD_SalesOrderReport;1]
main SP and [SD_GetBatchReportDetails;1]
subreport SP.
如果有人可以为此提供解决方案,这将是巨大的。如果在设计中进行一些更改请分享图片。谢谢。
It would be great if someone can provide a solution for this.If there are some changes to be made in designed please share images.Thank you.
推荐答案
最后经过了很多步道,我已经解决了。我使用了相同的参数名称Main和SubReport,下面使用代码设置其参数
Finally after lot of trails, I have solved it.May be this will be helpful to others.I have used the same parameter Name for Main and SubReport, used below code to set its parameter
objReportDocument.SetParameterValue("@QuoteID", ValQuoteID,objReportDocument.Subreports[0].Name.ToString());
这篇关于如何将参数发送到Crystal Reports中的子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!