Thema: Delphi search in database

Einzelnen Beitrag anzeigen

mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#1

search in database

  Alt 22. Jul 2007, 12:03
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
  Mit Zitat antworten Zitat