Lazarus

Programming => Databases => Topic started by: linuxdesire on August 12, 2020, 08:38:19 pm

Title: Searching more than one Criteria
Post by: linuxdesire 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.  
                                                   
Title: Re: Searching more than one Criteria
Post by: paweld 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
Title: Re: Searching more than one Criteria
Post by: mangakissa 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.
TinyPortal © 2005-2018