 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
miroo Guest
|
Posted: Thu Jun 15, 2006 9:30 pm Post subject: Filtering a TADOQuery causes an error |
|
|
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. |
|
| Back to top |
|
 |
Viatcheslav V. Vassiliev Guest
|
Posted: Thu Jun 15, 2006 11:25 pm Post subject: 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 (AT) pobox (DOT) sk> сообщил/сообщила в новостях следующее:
news:44918b27$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
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. |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|