Visual Studio .NET - Data retrival faliled for subreport (using Report Viewer / RDLC)

Asked By robin on 10-Dec-13 08:21 PM

I created a Main Report (works fine) but the connected subreport is not working -  "Data retrieval failed for the subreport, <subreport name> located at: <correct path\<name>.rdlc>

(VS2010)

The datasets contain the correct contents - there are 2 datasets in the main report and 1 data set in subreport
Parameter being passed is same name in both Main Report and SubReport

what am I missing?

Here is the code from .aspx :

  <rsweb:ReportViewer ID="ReportViewer" runat="server" Font-Names="Verdana"
  Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
  WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="1366px"
  Height="843px">
  <LocalReport ReportPath="PCEExport3.rdlc">
  <DataSources>
  <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="Dataset_Basic" />
  <rsweb:ReportDataSource DataSourceId="ObjectDataSource3"
  Name="Dataset_Tactic" />
  </DataSources>
  </LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
  SelectMethod="GetData"
  TypeName="PCE.PCEExport3TableAdapters.USP_PCEExportEventInfo_BasicTableAdapter"
  OldValuesParameterFormatString="original_{0}">
  <SelectParameters>
  <asp:ControlParameter ControlID="txtEventID" Name="EventID" PropertyName="Text"
  Type="Int32" />
  </SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource3" runat="server"
  SelectMethod="GetData"
  TypeName="PCE.PCEExport3TableAdapters.USP_PCEExportEventInfo_TacticTableAdapter"
  OldValuesParameterFormatString="original_{0}">
  <SelectParameters>
  <asp:ControlParameter ControlID="txtEventID" Name="EventID" PropertyName="Text"
  Type="Int32" />
  </SelectParameters>
</asp:ObjectDataSource>
 
  <asp:TextBox ID="txtEventID" runat="server" Visible="false"></asp:TextBox>

Here is the code from the .aspx.cs file:

  protected void Page_Load(object sender, EventArgs e)
  {
  if (!this.IsPostBack)
  {
  int intRecordID = PCE.Utils.StringToInt(Request.QueryString["RecID"]);
  intEventID = intRecordID;   // global parameter
 
  txtEventID.Text = Request.QueryString["RecID"];
 
  ReportViewer.Visible = true;
  SqlConnection thisConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["PCE"].ToString());
 
  DataSet DS_basic = new DataSet();
  DataSet DS_Cost = new DataSet();
  DataSet DS_Tactic = new DataSet();
  SearchValue[0] = new SqlParameter("@EventID", intRecordID);
 
  /* Put the stored procedure result into a dataset */
 
  DS_basic = SqlHelper.ExecuteDataset(thisConnection, "USP_PCEExportEventInfo_Basic", SearchValue);
  DS_Cost = SqlHelper.ExecuteDataset(thisConnection, "USP_PCEExportEventInfo_Cost", SearchValue);
  DS_Tactic = SqlHelper.ExecuteDataset(thisConnection, "USP_PCEExportEventInfo_Tactic", SearchValue);
 
 
  /* Associate thisDataSet  (now loaded with the stored procedure result) with the  ReportViewer datasource */
  ReportDataSource datasource = new ReportDataSource("Dataset_Basic", DS_basic.Tables[0]);
 
  ReportViewer.LocalReport.DataSources.Clear();
 
  ReportViewer.LocalReport.DataSources.Add(datasource);
  datasource = new ReportDataSource("Dataset_Cost", DS_Cost.Tables[0]);
  ReportViewer.LocalReport.DataSources.Add(datasource);
  datasource = new ReportDataSource("Dataset_Tactic", DS_Tactic.Tables[0]);
  ReportViewer.LocalReport.DataSources.Add(datasource);
 
  ReportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(CostSubreportEventHandler);
 
  ReportViewer.LocalReport.Refresh();
 
  }
  }
 
 
  void CostSubreportEventHandler(object sender, SubreportProcessingEventArgs e)
  {
  SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PCE"].ToString());
  //var mainSource = ((LocalReport)sender).DataSources["Dataset_Cost"];
  DataSet DS_EventCost = new DataSet();
  SearchValue[0] = new SqlParameter("@EventID", intEventID);
 
  /* Put the stored procedure result into a dataset */
 
  DS_EventCost = SqlHelper.ExecuteDataset(conn, "USP_PCEExportEventInfo_Cost", SearchValue);
  e.DataSources.Add(new ReportDataSource("Dataset_Cost", DS_EventCost.Tables[0]));
  }
 
  }
}