Board index » delphi » Zero-length string in predicate causes TADOQuery to blow

Zero-length string in predicate causes TADOQuery to blow

Has anyone else experienced this problem?:

with MyAdoQuery do
    begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT * FROM table WHERE column1 = :AValue');
    Parameters[0].Value := AValue;
    Open;
    end;

If AValue is zero-length, when Open is called, this message is returned:

    EOleException 'Parameter object is improperly defined.  Inconsistent or
incomplete information was provided'.

This problem doesn't exist under BDE.  Is this something I'll have to trap
for when using ADO, or am I missing some configuration parameter somewhere?

Regards,

Dan Brewer

 

Re:Zero-length string in predicate causes TADOQuery to blow


If AValue is supposed to be an empty string, try setting it to NULL
before sending the SQL.  Access will allow string fields that cannot
be zero-length, but can be NULL.
Jason Swager

Quote
"Dan Brewer" <d...@jobboss.com> wrote in message

news:3a747e21$1_2@dnews...
Quote
> Has anyone else experienced this problem?:

> with MyAdoQuery do
>     begin
>     Close;
>     SQL.Clear;
>     SQL.Add('SELECT * FROM table WHERE column1 = :AValue');
>     Parameters[0].Value := AValue;
>     Open;
>     end;

> If AValue is zero-length, when Open is called, this message is
returned:

>     EOleException 'Parameter object is improperly defined.
Inconsistent or
> incomplete information was provided'.

> This problem doesn't exist under BDE.  Is this something I'll have
to trap
> for when using ADO, or am I missing some configuration parameter
somewhere?

> Regards,

> Dan Brewer

Other Threads