I'm trying to export a crystal report to pdf and then email it, but every time I get to the export command, I get a ParameterFieldCurrentValue exception.
I've traced the values of the Parameter collection in the ReportDocument and the values are being set there. Also, all four parameters are strings. The first one is set to allow more than one value and also either discrete or range values. The dialog I call sets values for the choosable selections for that parameter. There are no other parameter fields. There are formula fields, in the report however.
My code is:
SelectionDialog sd = new SelectionDialog(null, null,
@"\\er1\common\bfi_apps\ReportMasterTwo\eds\custno.csv", true, false);
DialogResult dr = sd.ShowDialog();
string filename = @"c:\documents and settings\aap\desktop\salesanalysis.pdf";
if (dr == DialogResult.OK && sd.selectedVals != null)
{
for (int i = 0; i < sd.selectedVals.Count; i++)
{
ar100SalesABC_edcustom1.Parameter_Customer_Number.CurrentValues.AddValue
(sd.selectedVals[i]);
}
ar100SalesABC_edcustom1.Parameter_Fiscal_period.CurrentValues.AddValue("1");
ar100SalesABC_edcustom1.Parameter_Fiscal_year.CurrentValues.AddValue("2007");
ar100SalesABC_edcustom1.Parameter_Product_Type.CurrentValues.AddValue("F");
ar100SalesABC_edcustom1.ExportToDisk
(ExportFormatType.PortableDocFormat, filename); // ERROR HAPPENS HERE
// .. emailing code and other stuff
}
What am I doing wrong? Is there some other way of doing this that is better? I have tried export options, I have tried SetParameter, I keep getting that error.