We are trying to use untyped reports in a C# application. Since the reports
are being written by a third party the connection information needs changed
at runtime. It will always be a ODBC SQL server database. I tried using a
function from Chapter17 of Brian Bischof's book "Crystal Reports .NET
Programming", however it does not work.
What am I missing?
private void
LogonToDatabase(CrystalDecisions.CrystalReports.En gine.ReportDocument report,
string serverName, string databaseName, string userId, string password)
{
CrystalDecisions.Shared.ConnectionInfo connectionInfo = new
CrystalDecisions.Shared.ConnectionInfo();
connectionInfo.ServerName = serverName;
connectionInfo.DatabaseName = databaseName;
connectionInfo.UserID = userId;
connectionInfo.Password = password;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in
report.Database.Tables)
{
CrystalDecisions.Shared.TableLogOnInfo logonInfo = table.LogOnInfo;
logonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(logonInfo);
if (table.Location != table.Name)
{
table.Location = table.Name;
}
}
}