Skip to Content
Former Member
Mar 10, 2009 at 03:14 PM

How to assign NULL Value to Crystal Parameters


We are using Crystal 2008 in VS2003. We need to assign NULL value to Crystal parameters: Boolean, Currency, Date, DateTime, Time, Number, String.

When the NULL value is assigned, the exception thrown

"The types of the parameter field and parameter field current values are not compatible."

ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition  crParameterFieldDefinition;
ParameterValues crParameterValues;
ParameterDiscreteValue crParameterDiscreteValue;

crParameterFieldDefinitions = crReportDocument.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions[paramName]; // parameter Name

crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterDiscreteValue = new ParameterDiscreteValue();
if (paramValue == System.DBNull.Value)
        crParameterDiscreteValue.Value = null;
        crParameterDiscreteValue.Value = paramValue; // this is object wit the parameter value entered by the user


We have a propetarian OLEDB that talks to Crystal. When NULL value is assigned, all possible values of the parameters are used in the query -that is there is no filtering based on the parameter value. On previous Crystal .NET versions and in the COM components you could set the parameter value to NULL/Nothing, now in Crystal 2008 it seems that this is not possible, however we still need this functionality.

How do we set the value to NULL in Crystal 2008?