Hello all,
I have been converting a number of Crystal Reports from one version of my company's product to the new one, which is built on .NET 4.0. I have successfully converted a number of reports, but when I came to the one which is currently giving me trouble, I found that the Table.Location setter function was not functioning properly.
Background: This product makes extensive use of temporary user tables, which are created in the active user's database schema. For example, if my user name is sschaffer, I might create a report which links to sschaffer.temptable, but when user2 logs in, the report had better be looking at user2.temptable. This is working for most of my reports, but on one given report file, when I come to the code line "Table.Location = Connection.UserID + '.' + Table.Name;", the table location does not change.
This is the relevant code:
ConnectionInfo Connection = new ConnectionInfo();
Connection.UserID = Database.User;
Connection.Password = Database.OraclePassword;
Connection.ServerName = GolConfig.Database.Instance;
Report.SetDatabaseLogon(Connection.UserID, Connection.Password, Connection.ServerName, "");
foreach (CrystalDecisions.Shared.IConnectionInfo connection in Report.DataSourceConnections)
{
connection.IntegratedSecurity = true;
for (int i = 0; i < Report.DataSourceConnections.Count; i++)
{
Report.DataSourceConnections<i>.SetConnection(Connection.ServerName, "", Connection.UserID, Connection.Password);
}
}
foreach (Table Table in Report.Database.Tables)
{
TableLogOnInfo Info = Table.LogOnInfo;
Info.ConnectionInfo = Connection;
Table.ApplyLogOnInfo(Info);
Table.Location = Connection.UserID + '.' + Table.Name;
}
foreach (GolReport subReport in Subreports)
{
ReportDocument subRpt = subReport.Report;
subRpt.SetDatabaseLogon(Connection.UserID, Connection.Password, Connection.ServerName, "");
foreach (Table Table in subRpt.Database.Tables)
{
TableLogOnInfo Info = Table.LogOnInfo;
Info.ConnectionInfo = Connection;
Table.ApplyLogOnInfo(Info);
Table.Location = Connection.UserID + '.' + Table.Name;
}
}
I have verified that, at the time when the program attempts to change the table location, the table at the given location does exist. I am stumped as to why this would work for all reports except one. Any help would be appreciated.
Thank you for your time.