We have a lot of problems when we came to link the crystal report with another database to the one that it was designed / created against. As a result, we created the following function for proper configuration. It recursively establishes a join in all report tables and auxiliary reports.
In addition, I seem to remember that we had problems if the report was designed using integrated Windows authentication and started with a simple username and password. Therefore, we always made sure that we developed reports with a simple connection of the username and password to the database.
private static void SetConnection(ReportDocument report, string databaseName, string serverName, string userName, string password) { foreach (Table table in report.Database.Tables) { if (table.Name != "Command") { SetTableConnectionInfo(table, databaseName, serverName, userName, password); } } foreach (ReportObject obj in report.ReportDefinition.ReportObjects) { if (obj.Kind != ReportObjectKind.SubreportObject) { return; } var subReport = (SubreportObject)obj; var subReportDocument = report.OpenSubreport(subReport.SubreportName); SetConnection(subReportDocument, databaseName, serverName, userName, password); } } private static void SetTableConnectionInfo(Table table, string databaseName, string serverName, string userName, string password) {
source share