I have a crystal report that has a subreport embedded in it's footer. The reports individually work fine, but when I run together, I don't get data in the subreport. I have verified that the data exists in my 2 datasets, and I get data for my primary report, but not the sub. What am I missing? (VS 2008 4.0 .NET Framework)
// check whether the dataset is manual; if so add the subreport queries
if (AARpt.HasSubreports)
{
string srName;
string sProc;
using (AAData dc = new AAData(AAApp, true))
{
for (int i = 0; i < cRpt.ReportDefinition.ReportObjects.Count; i++)
{
ReportObject CurrentObject = cRpt.ReportDefinition.ReportObjects[i];
if (CurrentObject.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)
{
SubreportObject sr = (SubreportObject)CurrentObject;
rd = sr.OpenSubreport(sr.SubreportName );
srName = sr.SubreportName;
if (AARpt.SubReps.TryGetValue(srName, out sProc))
{
dsSubRept = dc.LoadSet(sProc);
if (dsSubRept != null)
{
DataTable dt1 = ds.Tables["MyTable"];
rd.SetDataSource(dt1);
rd.VerifyDatabase();
}
else
{
MessageBox.Show("We're sorry, but an error was encountered attempting to create this report","Utility", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
}
}
}
}
}
public DataSet LoadSet(SqlCommand _cmd)
{
// returns table "MyTable"
SqlDataAdapter DA;
DataSet DS = new DataSet();
_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Connection = _Conn;
DA = new SqlDataAdapter(_cmd);
DA.Fill(DS, "MyTable");
return DS;
}