home rezaei
home rezaei

Reputation: 11

Using OR with AND conditions Simultaneously into AdoTable Filter in Delphi

I am tryin to apply following filter on a AdoTable component but it shows error:

((details_id = 15) OR (details_id = 16) OR (details_id = 17)) AND(personel_id = 5)

the error is :

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

whats the wrong and how can I do this filter. I previously searched it on Delphi help but could not to solve it. Special Thanks in advance.

Upvotes: 1

Views: 557

Answers (1)

ivo.tisljar
ivo.tisljar

Reputation: 197

If you are trying to make a filter on a table it is much more convenient to use TADOQuery and put:

TADOQuery.SQL.Text := 'SELECT * FROM TableName WHERE ((details_id = 15) OR (details_id = 16) OR (details_id = 17)) AND (personel_id = 5)'

where TableName is the name of your actual table. It is also much easier to manipulate with parameter values this way.

Even better you can write this:

TADOQuery.SQL.Text := 'SELECT * FROM TableName WHERE ((details_id IN (15, 16, 17)) AND (personel_id = 5)'

Upvotes: 1

Related Questions