Tuesday, March 27, 2012

changing the server used by a report

hopefully have better luck with this.

I have two servers running the same database for two locations, I have a site setup to report for one of them and I want to make it report for both based on what location a person is in.

I have it working when there are no parameters, however as soon as you enter parameters into the mix it breaks.

here is what I use to do it when no parameters are required.

CrystalReportSource1.ReportDocument.DataSourceConnections[0].SetConnection(myConnectionInfo.ServerName, myConnectionInfo.DatabaseName, false);

CrystalReportSource1.ReportDocument.DataSourceConnections[0].SetLogon(myConnectionInfo.UserID, myConnectionInfo.Password);

I tried to put this in various locations, before the parameters are read, after reading but before setting, after everything.
Even before the report is loaded!

all gave me an error on the report.

I also tried to grab the parameter definitions, then set these and then copy the definitions back and that failed, it was read only.

Any ideas?

ThanksNM - threw in a verifydatabase on the report document and all is well.

No comments:

Post a Comment