Improving Crystal Reports Performance

If we need to set the database logon info at runtime, i.e, changing Server name, Database name, User Id or Password we need to implement some code similar to:

ConnectionInfo connectionInfo = new ConnectionInfo();
TableLogOnInfo tableLogonInfo = new TableLogOnInfo();

connectionInfo.ServerName = “myServer”;
connectionInfo.DatabaseName = “myDatabase”;
connectionInfo.UserID = “user”;
connectionInfo.Password = “password”;

Tables tables = reportDocument.Database.Tables;

foreach (Table table in tables)
{
 tableLogonInfo = table.LogOnInfo;
        tableLogonInfo.ConnectionInfo = connectionInfo;
        table.ApplyLogOnInfo(tableLogonInfo);
}

In Crystal Reports XI, if the original connection info differs from the current settings, this process happens to be very time consuming and directly proportional with the number of tables in the report!

We can dramatically improve the response time of the printing requests from the second invocation of the report. To do so we just save the report after setting the connection info for each table:

reportDocument.SaveAs(reportDocument.FileName);

Now the subsequent calls to this report will be much faster because the Crystal Engine verifies that we are not changing the logon info.

Advertisements

2 thoughts on “Improving Crystal Reports Performance

  1. António Fernandes says:

    Olá, Rui.

    Quando a base de dados é um dataset, supostamente não deverá existir um loguin. No entanto ocrystal continua a pedir um loguin. Alguma ideia como ultrapassar isto ?

  2. Rui Silva says:

    Unfortunatly I don’t have experience using Crystal Reports and DataSets. Sorry.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: