Re: Filtering a TADOQuery causes an error



From description of Filtered property (ADO recordset):

There is no precedence between AND and OR. Clauses can be grouped within
parentheses. However, you cannot group clauses joined by an OR and then join
the group to another clause with an AND, like this:

(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'

Instead, you would construct this filter as

(LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND
FirstName = 'John')

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)


"miroo" <sunlite@xxxxxxxx> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:44918b27$1@xxxxxxxxxxxxxxxxxxxxxxxxx

Hello, I tried something like this: on empty form I put an object of
TADOQuery class(Query1) and objects of these classes: TDataSource (to
connect the Query1), TSDBGrid (to show results), TButton (to fire an
action) and wanted to use a Filter property of the Query1 object. So I put
a text like this in that property - ' ( ( curr_code = ''USD'' ) or (
curr_code = ''SKK'') ) and ( some_string_field = ''V'' ) ' and set the
Filtered property to TRUE. Then I tried to open the query, but Calling
Query1.Open procedure raised an exception of EOleException class with this
message - 'Arguments are of the wrong type, are out of acceptable range,
or are in conflict with one another'. I want to ensure you that all the
fields were present in the table and data type of every field is String.
However, and it's interesting, when I changed operator OR to AND,
everything worked fine. So, if there's a more complicated expresion(like
combination of AND and OR operators), it causes an error. As an underlying
database was used MSSQL server 8 (9). Ado version is 2.8 SP1. Any idea?
Please help.


.


Quantcast