More info on problem with NULL parameter values in ADO
I have a dbCommand Object which takes 5 input parameters and returns a
cursor.
The stored procedure being called is a searching one and thus the input
parameters
may be null if these fields are not to be searched on.
The input parameters to the stored procedure consist of 4 string values and
a date and any of these values may contain null.
The procedure i use to add the parameters to the ADOCommand object is as
follows
procedure addParam
(
const dbCommand : TADOCommand;
const direction : TParameterDirection;
const paramName : WideString;
const paramValue : Variant
);
var
parameter : TParameter;
begin
parameter :=
dbCommand.Parameters.AddParameter;
parameter.Direction := direction;
parameter.name := paramName;
parameter.Value := paramValue;
end;
Before this procedure is called the DbCommand has already been connected and
all other paramerters cleared from it.
When I try passing in unassigned value or null for the 'paramValue' Delphi
raises an exception
However if i ensure that all parameters have an initial value either a
single blank character or an arbitrary date then the
stored procedure executes and returns a recordset with no problems.