Recent

Author Topic: filtered dbgrid  (Read 1091 times)

cryptid

  • Newbie
  • Posts: 3
filtered dbgrid
« on: April 01, 2021, 11:23:41 am »
filter db grid not work


procedure TForm1.Edit1Change(Sender: TObject);
begin
       SQLQuery1.Filtered:=False;
       SQLQuery1.Filter:='name' + 'LIKE' + QuotedStr(Edit1.Text );
        SQLQuery1.Filtered:=True;
end;   

wp

  • Hero Member
  • *****
  • Posts: 8408
Re: filtered dbgrid
« Reply #1 on: April 01, 2021, 11:49:19 am »
Without spaces around 'LIKE' the three parts in your filter text, 'name', 'LIKE', condition, will not be separate words.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Joek

  • New Member
  • *
  • Posts: 24
Re: filtered dbgrid
« Reply #2 on: April 02, 2021, 05:26:18 pm »
A small example: this works for me with LIKE ...
Code: Pascal  [Select][+][-]
  1. procedure TFOhlaseni.FilterKodChange(Sender: TObject);
  2. var sImput:string;
  3. begin
  4.     sImput:=FilterKod.Text;
  5.     DMOhlaseni.DSIBOhlaseni.Filtered := false;
  6.     DMOhlaseni.DSIBOhlaseni.Filter := 'KOD_OHLASENI LIKE ' + QuotedStr(sImput+'%');
  7.     DMOhlaseni.DSIBOhlaseni.Filtered := true;
  8. end;    

flori

  • Full Member
  • ***
  • Posts: 185
Re: filtered dbgrid
« Reply #3 on: April 07, 2021, 02:58:22 pm »
Code: Pascal  [Select][+][-]
  1. SQLQuery1.Active:=false;
  2. SQLQuery1.SQL.Clear;
  3. SQLQuery1.SQL.Append('select * from log WHERE user LIKE '''+edit1.Text+'%''');
  4. SQLQuery1.Active:=true

 

TinyPortal © 2005-2018