I have a Crystal 2008 report I've created, and I want to display this report in my C# application. The user can choose to have the report get its data from one of two different databases. In my code, I'm changing the data source as follows:
if (site == "PBG")
reportDocument.DataSourceConnections[0].SetConnection("Server1", "MESProduction", "User", "Password");
else
reportDocument.DataSourceConnections[0].SetConnection("Server2", "MESProduction", "User", "Password");
reportDocument.DataSourceConnections[0].IntegratedSecurity = false;
The report was created using the first connection information. If the user selects this database to pull data from, the report works fine. If he/she chooses the second, the report doesn't work.
Two questions: 1) Is this the correct way of setting the server/database source for the report dynamically at runtime? 2) If it is the correct way, why doesn't the report work when the user selects the second server/database? The schema of the database is exactly the same as the first.