TADOQuery Filter Errors

Posted on 2008-11-05
Last Modified: 2012-08-14
Hi all,

We have a SQL database that is being accessed over vpn from many offices.  In an effort to increase speed we are trying to use the filter property instead of rerunning the sql statement for various user actions.  With simple filters it seems to work fine, but eventually errors out with 'Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another'.  Is there any limit to parameters or any reason why this should be failing?  Here is an example of a filter I am using.  

((EcyToday = 1) AND ((Lookup_Name like '%dav%') OR (Acct#1 like '%dav%') OR (Acct#2 like '%dav%') OR (ARMAcct like '%dav%') OR (City like '%dav%') OR (State like '%dav%') OR (WorkPhone like '%dav%') OR (HomePhone like '%dav%') OR (CellPhone like '%dav%')))

If you run just the EcyToday = 1  OR you run just the second half, it works fine.  But it will not run with both sets of parameters.  

Any help is greatly appreciated!
Question by:Chipmunk77
    LVL 15

    Assisted Solution

    I don't think you can do nested OR's like that with a separate AND on the outside using filtering.
    Well from the short bit of testing I've done it doesnt seem to work.

    Author Comment

    Hmm..  you may be right..  I don't see anything in Delphi that says it shouldn't be allowed, but it sure doesn't like it.  
    Any ideas on a workaround or a way to make it accept the changes?  I cannot go back to the server as this was the original setup (and still is when the user is not remote) and the time to push the volumes of data back for a search was too long.  

    Accepted Solution

    aha!  Found the answer on a translated site...
    You cannot do ((A OR B)) AND (C)     but      you are allowed to do (A AND C) OR (A AND B)
    LVL 15

    Expert Comment

    Yep thought I was right Chipmunk77 :o)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now