views:

667

answers:

1

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.

A: 

I ended up using SetParameter instead of the current values method and using a values collection for the multi-valued parameter.

Also instead of using the typed report, I used an untyped report document.

I also copied over the sql from Crystal Reports and used it to make a dataset. I think the dataset was the part I was missing before.

It works now, although it looks nothing like the code above.

Tony Peterson