Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Pass Connection String to Subquery Post Reply Post New Topic
Author Message
ryeradio
Newbie
Newbie
Avatar

Joined: 19 Feb 2009
Location: United States
Online Status: Offline
Posts: 1
Quote ryeradio Replybullet Topic: Pass Connection String to Subquery
    Posted: 19 Feb 2009 at 10:29am
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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.