1504651 - How to determine if a parameter field is used in a Crystal Report using the .NET SDK

SAP Knowledge Base Articles - public

1504651 - How to determine if a parameter field is used in a Crystal Report using the .NET SDK


Error in File {23BBD53D-46B0-4749-90DS-C3DDE2240141}.rpt: Invalid parameter name.

Stack trace:

" at                                                                                                                                
CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e) at                                           
(Exception exception) at                                                                                                            
(RequestContext reqContext) at                                                                                                      
CrystalDecisions.Web.ReportAgent.ReportClosedExceptionHandlingReportSource.GetReportInfo(RequestContext reqContext) at              
CrystalDecisions.Web.ReportAgentBase.GetReportInfo() at                                                                             
CrystalDecisions.Web.ReportAgentBase.get_IsLogOnInfoUsingIntegratedSecurity() at CrystalDecisions.Web.ReportAgentBase.FillReportState                                                                                                                           
(RequestContext request) at
(Boolean bSeparatePages) at                                                                                                         
CrystalDecisions.Web.CrystalReportViewer.GetPage() at                                                                               
CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e)"                                                                  


The parameter field exists in the report, but is not used in the report, and values are being set to this parameterfield at runtime.


  • In the Report Application Server (RAS) sdk, parameterfields have a Usage property that can be used to determine various usage options of the parameterfield.
  • The integer value returned by ParameterField.Usage is a summation of the usage enum values derived from CrParameterFieldUsageEnum.
  • The following Usage enumerators and thier integer values are available:

CrParameterFieldUsageEnum.crParameterFieldUsageCurrentValuesProvidedByServer = 4
CrParameterFieldUsageEnum.crParameterFieldUsageDataFetching = 32
CrParameterFieldUsageEnum.crParameterFieldUsageEditableOnPanel = 16
CrParameterFieldUsageEnum.crParameterFieldUsageUsageInUse = 1
CrParameterFieldUsageEnum.crParameterFieldUsageIsLinked = 64
CrParameterFieldUsageEnum.crParameterFieldUsageNotInUse = 2
CrParameterFieldUsageEnum.crParameterFieldUsageShownOnPanel = 8
CrParameterFieldUsageEnum.crParameterFieldUsageUnKnown = 0

  • To determine if one of these enumerations is used by a parameterfield, perform a bitwise AND operation on the enumerator and the value returned by the ParameterField.Usage property.  If the result of the bitwise AND is non-zero, then that particular enumerator is 'Used' and set in the parameterfield.
  • For example, if a parameter field was created in the designer with the following value option:

Show on (Viewer) Panel = Editable

then it would contain the following enums:

CrParameterFieldUsageEnum.crParameterFieldUsageEditableOnPanel = 16
CrParameterFieldUsageEnum.crParameterFieldUsageShowOnPanel = 8

If the parameter field is not used in the report, then it would also have the following enum:

CrParameterFieldUsageEnum.crParameterFieldUsageNotInUse = 2

  • The summation of these enums  (16 + 8 + 2 = 26) would be the integer value returned by ParameterField.Usage.
  • Using the above example, we can use the SDK to determine if the parameter field is used in the report.

26 AND 2 = 2

or looking at the bit mask:

       11011   (26)
AND 00010    (2)
       00010   (2)  <-- result is crParameterFieldUsageNotInUse is true.

  • The following code demonstrates how to determine if a parameterfield is used in a report:


If (paramField.Usage And Convert.ToInt16(CrParameterFieldUsageEnum.crParameterFieldUsageNotInUse)) <> 0 Then
    'Field is not used on the report
    'Field is used on the report since the AND operation returned zero
End If


if(((int)pfld.Usage & (int)CrParameterFieldUsageEnum.crParameterFieldUsageNotInUse) != 0)
    //Field is not used on the report
    //Field is used on the report since the AND operation returned zero




invalid parameter name; SDK, RAS, .NET, 2008, crystal reports, parameterfield, InUse, , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To


Crystal Reports 2008 V0 ; Crystal Reports 2008 V1