Wednesday, April 11, 2012

Application runs slow when DB logging info is applied to each Crystal Reports Sections

Currently I use the following method to assign connection info to all the report sections. But as I have many sections in the report, the report is displayed after almost 10 seconds. Which looks really slow. Is there some other method by which we can set logon information to each CR once and for all when it is installed at client side.

JFYI: All the CRs connect to same DB, with same login credentials. Thank you in advance.

   readDiamondBillReport = new RealDiamondBill();
crConnectionInfo.ServerName = db.Connection.DataSource;
crConnectionInfo.DatabaseName = db.Connection.Database;
crConnectionInfo.UserID = "client";
crConnectionInfo.Password = "client";
crConnectionInfo.IntegratedSecurity = false;

CrTables = readDiamondBillReport.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;

Sections crSections2 = readDiamondBillReport.ReportDefinition.Sections;
// loop through all the sections to find all the report objects
foreach (Section crSection in crSections2)
ReportObjects crReportObjects = crSection.ReportObjects;
//loop through all the report objects in there to find all subreports
foreach (ReportObject crReportObject in crReportObjects)
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
SubreportObject crSubreportObject = (SubreportObject)crReportObject;
//open the subreport object and logon as for the general report
ReportDocument crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);

Tables SubCrTables = crSubreportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table SubCrTable in SubCrTables)
crtableLogoninfo = SubCrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;



No comments:

Post a Comment