Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 views
in Technique[技术] by (71.8m points)

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.

question from:https://stackoverflow.com/questions/65680330/using-or-with-and-conditions-simultaneously-into-adotable-filter-in-delphi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...