ReportDocument.Load() taking too much time to load .RPT file in c#.net

65 views Asked by At
ReportDocument cryRpt = new ReportDocument();

SqlCommand MyCommand = new SqlCommand();

SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(cn.ConnectionString);
ConnectionInfo crConnectionInfo = new ConnectionInfo();

TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
string mtmptbl = "TmpAccountReport";

string qrySelBalanceSheet = "select * from tbl_TmpLedgerReport " + System.Environment.NewLine;

MyCommand = new SqlCommand(qrySelBalanceSheet, cn);
MyCommand.CommandType = CommandType.Text;

cn.Open();
MyCommand.ExecuteNonQuery();
cn.Close();

crystalReportViewer1.RefreshReport();
string crReportPath = Application.StartupPath.Replace("bin\\Release", "") + "\\Report";
cryRpt.Load(crReportPath + "\\LedgerAccountReport.rpt");

builder.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["con"];
string dbName = builder.InitialCatalog;
string dbDataSource = builder.DataSource;
string userID = builder.UserID;
string pass = builder.Password;
crConnectionInfo.ServerName = dbDataSource;
crConnectionInfo.DatabaseName = dbName;
crConnectionInfo.UserID = userID;
crConnectionInfo.Password = pass;

Tables Crtables;

Crtables = cryRpt.Database.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in Crtables)
{
    crtableLogoninfo = CrTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrTable.ApplyLogOnInfo(crtableLogoninfo);
}

crystalReportViewer1.ReportSource = cryRpt;                

As per my code, I am showing report through sap crystal report in C#. Now, at some point in time, my code gets stuck for 2-3 minutes at this line

cryRpt.Load(crReportPath + "\\LedgerAccountReport.rpt");

(I saw by debugging the code) and from that it takes more time to load the report.

Surprise is that this happening some times only in between doing work.

Is there any idea to solve this issue?

1

There are 1 answers

0
mweber On

Some years ago I've had a similar problem, that a report would render slow at every first call from within the .NET application. I tried to load a dummy report on app startup, but without much effect. It turned out that the crystal components tried to connect a verisign URL which was blocked by the firewall appliance of my customer, so that Crystal waited until this connection timed out. So I'd recommend you have a look into the network traffic, alternatively check if the problem persists when the application runs in an environment without firewall restrictions.