• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5361
  • Last Modified:

ADOTable + DBGrid in delphi

Hello!
I have a ADOTable and one DBGrid
I want to list in DBgrid only the record that match with one criteria
example
only names='john' or only ages > 20
thanks
0
tinti
Asked:
tinti
  • 3
  • 2
  • 2
  • +3
1 Solution
 
tintiAuthor Commented:
thanks
0
 
kretzschmarCommented:
adotable1.filter := 'names='+quotedstr('john');
adotable1.filtered := true;

or

adotable1.filter := 'ages > 20';
adotable1.filtered := true;

or

adotable1.filter := 'names='+quotedstr('john')+' and ages > 20';
adotable1.filtered := true;

meikl ;-)
0
 
tkalchevCommented:
Use the Filter property of your ADOTable, for example :


ADOTable1.Filter := 'names="john" or ages>20';
ADOTable1.Filtered := true;

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tkalchevCommented:
Ops, sorry kretzschmar, you post came while I was writing mine :)
0
 
kretzschmarCommented:
doesn't matter, tkalchev,
happens sometimes to me too :-))
0
 
rondiCommented:
Use the Filter property of ADOTable.

eg.

ADOTable1.Filtered := False;
ADOTable1.Filter := 'FirstName like ''*john*''';
ADOTable1.Filtered := True;


or

ADOTable1.Filtered := False;
ADOTable1.Filter := 'Age > 20';
ADOTable1.Filtered := True;
0
 
tintiAuthor Commented:
Ok
Sorry for delay
The points go to Kretzschmar
Thanks
0
 
kretzschmarCommented:
just press "accept comment as answer"
upper right of the comment which helps you most

meikl ;-)
0
 
DevNeoclesCommented:
I was just checking the filter to use in AdoTable and it worked like " xxxxx =' ss ' or yyyyyy = ' ff '  "
0
 
Stef MerlijnDeveloperCommented:
Hi,

How would I accomplish filtering on multiple fields?
This gives an error about using the wrong arguments the moment the filter is applied.
ADOTable1.Filtered := False;
ADOTable1.Filter := '(FirstName like "*john*") AND (Age > 20)';
ADOTable1.Filtered := True;

Open in new window

0
 
Stef MerlijnDeveloperCommented:
Sorry,

I meaned the following filter. (the previous will work)
ADOTable1.Filtered := False;
ADOTable1.Filter := '(FirstName like "*john*") AND ((Age < 5) OR (Age > 20))';
ADOTable1.Filtered := True;

Open in new window

0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now