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;
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:
Now the subsequent calls to this report will be much faster because the Crystal Engine verifies that we are not changing the logon info.