I am dynamically passing a connection to our Crystal Reports through our web service. But when I add in a subquery it does not pass the connectionto the subquery. THis is the code I have right now..can anyone tell me what I might be doing wrong?
#region Set Info for Subreports
// Get the connection information from the main table above.
ConnectionInfo crConnInfo = table_new.ConnectionInfo;
// Get the reports areas.
ReportDocument reportDoc = report.ReportDocument;
Areas rptAreas = reportDoc.ReportDefinition.Areas;
ReportObjects crReportObjects;
SubreportObject crSubreportObject;
// Holds the subreport name.
string srptName = string.Empty;
// Loop thru the report areas to find sections containing subreports.
foreach (Area crArea in rptAreas)
{
foreach (Section crSection in crArea.Sections)
{
//// Get the report objects for this section.
crReportObjects = crSection.ReportObjects;
foreach (ReportObject crReportObject in crReportObjects)
{
// Check for objects that are subreports.
if (crReportObject.Kind == CrReportObjectKindEnum.crReportObjectKindSubreport)
{
crSubreportObject = (SubreportObject)crReportObject;
// Set the subreport name.
srptName = crSubreportObject.SubreportName;
// Set the table and login credentials for the subreport.
foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table table in ((Database)report.SubreportController.GetSubreportDatabase(srptName)).Tables)
{
CommandTable new_table;
new_table = (CommandTable)table.Clone(true);
// Set the database login credentials.
new_table.ConnectionInfo = crConnInfo;
// Password has to be set explicitly.
new_table.ConnectionInfo.Password = Password;
// Store the new table information for the subreport.
report.SubreportController.SetTableLocation(srptName, table, new_table);
}
}
}
}
}
#endregion