Board index » delphi » Filterproblem with ADOQuery while mixing AND & OR operators

Filterproblem with ADOQuery while mixing AND & OR operators


2005-10-22 03:30:01 PM
delphi197
I try to set a filter on my ADOQuery like this:
(Name='John' OR Firstname='John') AND Birthdate>'2005-01-01'
When i do this, there comes up an EOleException which tells me that the
arguments are from the wrong type.
Following is working fine:
Name='John' OR Firstname='John') OR Birthdate>'2005-01-01'
and this also:
(Name='John' AND Firstname='John') AND Birthdate>'2005-01-01'
It seems that Delphi has a problem in mixing AND & OR Operators in the
filter.
I try to use the filter because the there are lots of data and i don't
want to open the query each time again if i try to search in it.
Same problem if i use another field for Birthday (string) instead of
the date-field.
Can somebody help me?
 
 

Re:Filterproblem with ADOQuery while mixing AND & OR operators

On 22 Oct 2005 00:30:01 -0700, Mani writes:
Quote
Can somebody help me?
Hoi Mani
You need to repost your question on the Borland news server to make
everybody see it and possibly answer your question.
Take a look here:
<tinyurl.com/8m5nw>
which links to
<delphi.wikicities.com/wiki/Delphi_Newsgroups>
 

Re:Filterproblem with ADOQuery while mixing AND & OR operators

Mani writes:
Quote
I try to set a filter on my ADOQuery like this:
(Name='John' OR Firstname='John') AND Birthdate>'2005-01-01'
When i do this, there comes up an EOleException which tells me that the
arguments are from the wrong type.
Following is working fine:

Name='John' OR Firstname='John') OR Birthdate>'2005-01-01'

and this also:

(Name='John' AND Firstname='John') AND Birthdate>'2005-01-01'

It seems that Delphi has a problem in mixing AND & OR Operators in the
filter.
Not Delphi but ADO itself.
You can always rewrite your filter expression to the one that will
work.
e.g. (Name='John' AND BirthDate>'2005-01-01') OR (Firstname='John'
AND Birthdate>'2005-01-01')
See Microsoft's Q235892 for details.