Recent

Author Topic: Searching more than one Criteria  (Read 947 times)

linuxdesire

  • New Member
  • *
  • Posts: 11
Searching more than one Criteria
« on: August 12, 2020, 08:38:19 pm »
I have a Tform1.btnSearchClick

I can search by "title" but when I try to put in "actor" it gives me an error. Here is what I have that is working.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.btnSearchClick(Sender: TObject);
  2. begin
  3.   SQLQuery1.locate('Title',edtSearch1.Text,[loCaseInsensitive,loPartialKey]);
  4. end;                                                                        
  5.  
         

If I try to put in 'Actor' I get the error:
unit1.pas (94,85)Error: Wrong number of parameters specified for call to "Locate"

It has the squiggly line under the ); at the end of the line.



Code: Pascal  [Select][+][-]
  1. procedure TForm1.btnSearchClick(Sender: TObject);
  2. begin
  3.   SQLQuery1.locate('Title', 'Actor',edtSearch1.Text,[loCaseInsensitive,loPartialKey]);
  4. end;                                                                        
  5.  
                                                   

paweld

  • Hero Member
  • *****
  • Posts: 970
Re: Searching more than one Criteria
« Reply #1 on: August 12, 2020, 09:10:35 pm »
If you want to take multiple columns, enter them in one string, separated by a semicolon. And the searched values as an array.
https://wiki.freepascal.org/locate
Best regards / Pozdrawiam
paweld

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Searching more than one Criteria
« Reply #2 on: August 13, 2020, 10:37:36 am »
But you can't search in two fields with one criteria.
If you want, you have to search twice.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018