Hi,
I am developing one Main rdlc Report Say "C" with Subreports A and B.Each report getting Data with different Datasources(DataSets).When Data is not coming for SubReports A and B, report is generated but I am getting the error message as Data retrieval failed for the subreport, 'Subreport1', located at:Location\SubTrade.rdlc. Please check the log files for more information. Please help me in this regard. Thanks in advance. Below is my piece of code.
private void ProcessMainReport()
{
LocalReport reportContractNote = new LocalReport();
reportContractNote.SubreportProcessing += new SubreportProcessingEventHandler(prcProcessSubReport);
reportContractNote.ReportPath = ReportPath;
ReportParameter recipientIDConsoCN = new ReportParameter(strparamRecipientIDConsoCN, RecipientID);
ReportParameter batchdateConsoCN = new ReportParameter(strparamBatchDateConsoCN, BatchDate.ToString());
ReportParameter transmittalreportIDConsoCN = new ReportParameter(strparamTransmittalReportIDConsoCN, TransmittalReportID.ToString());
ReportParameter datatypeConsoCN = new ReportParameter(strparamDataTypeConsoCN, DataType.ToString());
reportContractNote.SetParameters(new ReportParameter[] { recipientIDConsoCN, batchdateConsoCN, transmittalreportIDConsoCN, datatypeConsoCN });
DataTable dtConsolidatedContractNote = new DataTable();
dtConsolidatedContractNote = objBll.GetConsolidatedContractNoteData(RecipientID, BatchDate, TransmittalReportID, DataType);
reportContractNote.DataSources.Add(new ReportDataSource("DataSet1", dtConsolidatedContractNote));
}
private void prcProcessSubReport(object sender, SubreportProcessingEventArgs e)
{
DataTable dtSubReport = new DataTable();
try
{
switch (e.ReportPath)
{
case strSubTrade://Name of the Sub-report Trade Details
dtSubReport = objBll.GetTradeDetails(RecipientIDTradeDetails, BatchDateTradeDetails, TransmittalReportIDTradeDetails, 1);
ReportDataSource rdsTradeDetails = new ReportDataSource("DataSet1", dtSubReport);
e.DataSources.Add(rdsTradeDetails);
break;
case strSubRecDisb://Name of the Sub-Report Cash Details
dtSubReport = objBll.GetCashDetails(RecipientIDCashDetails, BatchDateCashDetails, TransmittalReportIDCashDetails, 2);
ReportDataSource rdsCashDetails = new ReportDataSource("DataSet1", dtSubReport);
e.DataSources.Add(rdsCashDetails);
break;
default:
break;
}
}
catch (Exception ex)
{
CommonFunctions.strTraceMsg = "Exception Occured in Method *prcProcessSubReport*. Error message:" + ex.Message;
if (CommonFunctions.strLogIsRequired == CommonFunctions.strLogYes)
objCommanFunc.LogEventToTextFile(CommonFunctions.strTraceMsg, CommonFunctions.strFilePath);
string strErrorMsgContractNote = ex.Message;
objCommanFunc.LogEventToEventViewer(strErrorMsgContractNote);
}
finally
{
dtSubReport = null;
}
}