SAP Knowledge Base Article - Public

1508642 - Error: "Invalid parameter name" when exporting a Crystal Report in a Visual Studio .NET application

Symptom

  • Exporting a Crystal Report using the ReportDocument SDK in a Visual Studio .NET application
  • Setting IsNoValue = true programmatically on an unused parameter field's CurrentValues collection 
  • An "Invalid parameter name" exception is thrown on the ReportDocument.Export() call
  • How to determine whether a parameter is in use on the report before assigning a parameter value?

Environment

Using the ReportDocument SDK in a Visual Studio .NET application

Resolution

The ReportDocument base class doesn't expose methods for determining parameter usage. However, it is possible to access the In-Process Report Application Server (RAS) SDK through the ReportClientDocument property of the ReportDocument object and determine whether a parameter has been used in the report before setting the value.

Sample code (VB.NET):

Dim objRCD As ISCDReportClientDocument = objRD.ReportClientDocument
Dim dataDefController As DataDefController = objRCD.DataDefController
Dim paramFields As Fields = objRCD.DataDefController.DataDefinition.ParameterFields
Dim paramField As CrystalDecisions.ReportAppServer.DataDefModel.ParameterField = paramFields(1)
Dim vals As New Values
vals.IsNoValue = True

If (paramField.Usage And Convert.ToInt16(CrParameterFieldUsageEnum.crParameterFieldUsageNotInUse)) <> 0 Then
    'Field IS NOT used on the report
Else
    'Field IS used on the report
    objRCD.DataDefController.ParameterFieldController.SetCurrentValues("", parameField.Name, vals)
End If

See Also

See SAP Knowledge Base Article 1504651 for additional information on parameter field usage enumeration flags in the RAS SDK.

Keywords

KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

Product

Crystal Reports Server XI R2