I have a report that I created with Crystal Reports 2008. This report uses upwards of 40 parameters to control the layout of the report. All the parameters are boolean and are defaulted to False in the saved report. The report is saved with the save data with the report option unchecked as I want to read the results from the database rather than within the report.
However, when I go to export the report to PDF I receive a ParameterFieldCurrentValueException. I do not receive this error when the data is saved with the report.
I have verified that all five tables in the report are connected to their data source with the following code.
foreach (Table table in reportDoc.Database.Tables)
{
bool isConnected = table.TestConnectivity();
Console.WriteLine(table.Name + " connected? " + isConnected.ToString());
}
What might be causing the ParameterFieldCurrentValueException when data not saved with a report and it is exported to disk?
This is the simplest code that can reproduce this issue.
string report = "list_report.rpt";
string pdf = "list_report.pdf";
ReportDocument reportDoc = new ReportDocument();
reportDoc.Load(report);
// Setting parameters (or not) does not have an effect on the error
// All parameters have defaults
// reportDoc.SetParameterValue("hideRegion", false);
reportDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, pdf);