I am working with RDLC reports and currently I have a sub report with its properties and parameters within a main report. After trying to generate the report, the below error is shown at the UI :
"Data retrieval failed for the subreport, 'Subreport1', located at: [C:/filepath]"
There is nothing error shown at Visual studio, so I thing the error may not cause by the code.
I think the error comes from the parameters at rdlc not being able to pass into the sub report via the main report . Below is my code:
public ReportViewer Main_Report(string path, ProgressReportFilter item, DataTable dt)
{
ReportViewer reportViewer = new ReportViewer();
try
{
var user = UserAccess.GetCurrentUser();
reportViewer.ProcessingMode = ProcessingMode.Local;
//reportViewer.LocalReport.ReportPath = @"Reports/Main_Report.rdlc";
reportViewer.LocalReport.ReportPath = path;
reportViewer.SizeToReportContent = true;
reportViewer.Width = Unit.Percentage(100);
reportViewer.Width = Unit.Percentage(100);
reportViewer.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("Year", item.yyyy));
reportViewer.LocalReport.SetParameters(new
Microsoft.Reporting.WebForms.ReportParameter("Month", item.mm));
ReportDataSource ds = new ReportDataSource("Main_DataSet", dt);
reportViewer.LocalReport.DataSources.Add(ds);
reportViewer.LocalReport.SubreportProcessing += new
SubreportProcessingEventHandler(Detail_Alco);
reportViewer.LocalReport.Refresh();
}
catch (Exception e)
{}
return reportViewer;
}
void Detail_Alco(object sender, SubreportProcessingEventArgs e)
{
Helper.log.Info("para is " + e.Parameters[0].Values[0]);
string serial = e.Parameters["serial"].Values[0].ToString();
//Helper.log.Info("serial is " + serial);
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("@serial", serial);
string spName1 = "SP_Report_MRS_Detail_Breakdown_Report_Sub_Alco";
SUSDB susdb = new SUSDB();
DataTable dtAlco = ReportHelp.ToDataTable(susdb.DetailBreakdownReport_SubReport_Alco(spName1, parameters));
ReportDataSource ds = new ReportDataSource("Detail_Breakdown_Alco", dtAlco);
e.DataSources.Add(ds);
}
Any help would be appreciated, many thanks