Hi Ludek,
Thanks for getting back to me. I am using the crystal reports that came with VS 2010 so version
13.0.2000.0. The last update I ran was CRforVS_13_0_5.exe. I use a Crystal Report Viewer control and below is the code that displays the report. I assumed once they close the report objects get discarded. The error message is: 'Load report failed' as you guessed correctly. Here's my code:
private void ConfigureCrystalReports()
{
try
{
ReportDocument crystalReport;
string FileName = null;
string reportPath = Server.MapPath(repFolder + "/" + repName + ".rpt"); //Gets the report file name
crystalReport = new ReportDocument();
crystalReport.Load(reportPath);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = SharedGlobal.ServerName();
connectionInfo.DatabaseName = SharedGlobal.DatabaseName();
connectionInfo.UserID = SharedGlobal.UserID();
connectionInfo.Password = SharedGlobal.Password();
crystalReport.SetDatabaseLogon(connectionInfo.UserID, connectionInfo.Password, connectionInfo.ServerName, connectionInfo.DatabaseName);
TableLogOnInfo tbLogOnInfo = new TableLogOnInfo();
tbLogOnInfo.ConnectionInfo = connectionInfo;
foreach (CrystalDecisions.CrystalReports.Engine.Table tb in crystalReport.Database.Tables)
{
tb.ApplyLogOnInfo(tbLogOnInfo);
}
SetCurrentValuesForParameterField(crystalReport.ParameterFields);
CrystalReportViewer1.ReportSource = crystalReport; // uses the crystal report viewer in the aspx file
}
catch (Exception ex)
{
// Code to report error
}
}