I dont have any subreports in my reports.
Here is the code i am testing at the moment:
CrystalDecisions.CrystalReports.Engine.ReportDocument myReport
= new CrystalDecisions.CrystalReports.Engine.ReportDocument();
myReport.Load(@reportPath);
Database crDatabase;
Tables crTables;
CrystalDecisions.CrystalReports.Engine.Table crTable;
TableLogOnInfo crTableLogOnInfo;
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = INIFile.IniReadValue("Server", "Server").ToString();
crConnectionInfo.DatabaseName = INIFile.IniReadValue("DBName", "DBName").ToString();
crConnectionInfo.UserID = INIFile.IniReadValue("UName", "UName").ToString();
crConnectionInfo.Password = INIFile.IniReadValue("PWord", "PWord").ToString();
crDatabase = myReport.Database;
crTables = crDatabase.Tables;
for (int i = 0; i < crTables.Count; i++)
{
crTable = crTables;
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
crTable.Location = "" +
crTable.Location.Substring(crTable.Location.LastIndexOf
(".") + 1);
}
crystalReportViewer1.ReportSource = myReport;
I receive the following error:
Logon failed.
Details: ADO Error Code: 0x
Source: Microsoft OLE DB Provider for SQL Server
Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
SQL State: 08001
Native Error:
I receive this error on the following row:
for (int i = 0; i < crTables.Count; i++)
with the "i++" highlighted as the problem
Also since i tried to change the datasource at runtime, everything is working so slow. Report usually takes up to a minute to throw up an error.
Thanks