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.


March 28, 2007 at 9:51 am |
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 ?
March 28, 2007 at 10:02 am |
Unfortunatly I don’t have experience using Crystal Reports and DataSets. Sorry.