AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

search in database

Ein Thema von mohfa · begonnen am 22. Jul 2007 · letzter Beitrag vom 22. Jul 2007
Antwort Antwort
mohfa

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

search in database

  Alt 22. Jul 2007, 11: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
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: search in database

  Alt 22. Jul 2007, 11:05
Have you tried .Filter ?
Or even better to switch to TQuery
Markus Kinzler
  Mit Zitat antworten Zitat
mohfa

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

Re: search in database

  Alt 22. Jul 2007, 11:14
ok mkinzler
how can we do that with TQuery


thank
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#4

Re: search in database

  Alt 22. Jul 2007, 11:23
.Sql.Text := 'select * from <Table> where <Field3> like + QuotedStr( '%'+strtobefound+'%')+';';
Markus Kinzler
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:52 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz