Usually when we trying to open reports in other systems(servers), which were created on some other machines.
The major cause of this is incorrect connection information.
On following the below steps we can come out from this problem.
We have a class in .net ConnectionInfo we can make use that.
In my example am taking a main report and a sub report.
MainReport report = new MainReport();
ReportDocument reportMain = new ReportDocument();
ReportMain = report;
//To Establish Connection to reports and subreports
ConnectionInfo myConnection = new ConnectionInfo();
myConnection.ServerName = servername;//Here server name is a string variable which holds the server name
myConnection.DatabaseName = databasename; //databasename
//if you have userid and password
myConnection.UserId = userid; //userid is local variable contains userid
myConnection.Password = pwd;//pwd containes password
//if Integrated security true then you can use below statement
myConnection.IntegratedSecurity = true;
//Here an calling a method to provide connection information to report
here am checking the each report object in the every section of the report.
If that report object is subreport then it is calling another method where it is providing the connection information to that subreport.
private void SetDBLogonForSubreports(ConnectionInfo myConnectionInfo, ReportDocument myReportDocument)
Sections mySections = myReportDocument.ReportDefinition.Sections;
foreach (Section mySection in mySections)
ReportObjects myReportObjects = mySection.ReportObjects;
foreach (ReportObject myReportObject in myReportObjects)
if (myReportObject.Kind == ReportObjectKind.SubreportObject)
SubreportObject mySubreportObject = (SubreportObject)myReportObject;
ReportDocument subReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName);
and the other method is here
private void SetDBLogonForReport(ConnectionInfo myConnectionInfo, ReportDocument myReportDocument)
Tables myTables = myReportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in myTables)
TableLogOnInfo myTableLogonInfo = myTable.LogOnInfo;
myTableLogonInfo.ConnectionInfo = myConnectionInfo;