Generate a Crystal Report with a Parameter

  • Thread starter Thread starter Philluminati
  • Start date Start date
P

Philluminati

I have a crystal report which I need my application to generate. I can
do it like this:

ReportDocument thisReport = new ReportDocument();
thisReport.Load(inFilename);
thisReport.Refresh();
thisReport.ExportToDisk(ExportFormatType.PortableDocFormat,outputFilename);
thisReport.Close();

This works perfectly. Now I have a crystal report that takes a
parameter called "FirewallId". I have tried to make the code like
this:

ReportDocument thisReport = new ReportDocument();
thisReport.Load(inFilename);
thisReport.SetParameterValue("FirewallId",25);
thisReport.Refresh();
thisReport.ExportToDisk(ExportFormatType.PortableDocFormat,outputFilename);
thisReport.Close();

but I get missing parameter value. When I inspect "thisReports" fields
I am told there are two *more* parameters both called intid. Setting
them gives me errors - You cannot set parameters on linked fields and
not setting them gives me missing parameters error.

Can anyone help me please?
 
Try something like this, to see all the Parameter fields, and then just set
them

foreach (ParameterField field in thisReport.ParameterFields)
{
MessageBox.Show(field.Name);
thisReport.SetParameterValue(field.Name,"whatevervalue");
}
 
I have a crystal report which I need my application to generate. I can
do it like this:

ReportDocument thisReport = new ReportDocument();
thisReport.Load(inFilename);
thisReport.Refresh();
thisReport.ExportToDisk(ExportFormatType.PortableDocFormat,outputFilename);
thisReport.Close();

This works perfectly. Now I have a crystal report that takes a
parameter called "FirewallId". I have tried to make the code like
this:

ReportDocument thisReport = new ReportDocument();
thisReport.Load(inFilename);
thisReport.SetParameterValue("FirewallId",25);
thisReport.Refresh();
thisReport.ExportToDisk(ExportFormatType.PortableDocFormat,outputFilename);
thisReport.Close();

but I get missing parameter value. When I inspect "thisReports" fields
I am told there are two *more* parameters both called intid. Setting
them gives me errors - You cannot set parameters on linked fields and
not setting them gives me missing parameters error.

Can anyone help me please?

Hi,

you use ReportDocument.SetParameterValue()
 
Back
Top