![]() |
search in database
i really need your help in this :
i have table contains 3 fields : 1st Field : Id ( integer ) 2nd Field : Categ ( string ) 3rd Field : Name ( String ) i'd like to seach the 3rd Field for a string , if the result is True then Display the result in a TListView like this : ID | Categ | Name i did it like this
Delphi-Quellcode:
ListView.Items.Clear;
if Found then // yes we find the searched word begin With MyTable do begin Close; Open; first; while not EOF do begin ListView1.Items.AddItem(nil); ListView1.Items[ListView1.Items.Count-1].Caption := FieldByName('ID').AsString; ListView1.Items[ListView1.Items.Count-1].SubItems.Add(FieldByName('Categ').AsString); Next; end; the problem here is that all records will be displayed , But i want only the found record to be displayed. thanks |
Re: search in database
Have you tried .Filter ?
Or even better to switch to TQuery |
Re: search in database
ok mkinzler
how can we do that with TQuery thank |
Re: search in database
Delphi-Quellcode:
.Sql.Text := 'select * from <Table> where <Field3> like + QuotedStr( '%'+strtobefound+'%')+';';
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:26 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz