Autor Beitrag
SadPa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 28

Win 2000; Win XP
D7 Entp
BeitragVerfasst: Fr 19.11.04 16:57 
Hallo,

ich schreib gerade an einer Datenbank (Paradox 7). Ich will nun nach dem Inhalt einzelner Datenbank-Felder suchen und diese in einem DBGrid ausgeben. Das klappt auch solange ohne probs, solange ich die Filterfunktion (FILTER; FILTERED) verwende und die einzelne Spalte in der gesucht werden soll angebe. Nun will ich aber 1. über die gesamte Tabelle suchen, und 2. soll es zur Suche und Ausgabe ausreichen, wenn ich z.B. "europa" in ein das Editfeld1 eingebe, aber im Tabellenfeld "der Europaabgeordnete Müller" steht. Also sowohl die Eingabe eines Teils des Feldes soll ausreichen, als auch die Groß- und Kleinschreibung soll keine probs machen, als auch nach Umlauten und Sonderzeichen soll gesucht werden können. Ich verwende eine Combobox zur Auswahl der Suche nach einer bestimmten Spalte, wenn in der Combobox Alle steht soll über die gesamte Tabelle gesucht werden.

Habe gedacht so könnte es aussehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
 IF combobox1.text = 'Alle' THEN
 BEGIN
   Query1.Active:=false;
   Query1.Sql.Clear;
   Query1.Sql.Add('Select * From Table1 where Name like %'+QuotedStr(Edit1.text)+'% | Adresse like %' +QuotedStr(Edit1.text)+'% '); {so hab ich dann einfach alle Spalten verknüpft}
   Query1.Active:=true;
   END;


Funkt aber nicht!

Was hab ich falsch gemacht?

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Fr 19.11.04 17:06 
hab dir mal die SQL Syntax für sone Abfrage aufgeschrieben:
ausblenden Quelltext
1:
2:
3:
SELECT * FROM Table1 
WHERE UPPER(Name) LIKE UPPER('%[DeinText]%')
OR UPPER(Adresse) LIKE UPPER('%[DeinText]%')


mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
SadPa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 28

Win 2000; Win XP
D7 Entp
BeitragVerfasst: Fr 19.11.04 17:39 
Thx!
Hab es gleich ausprobiert!

Hab es jetzt so:
Query1.Sql.Add('Select * From Table1 WHERE UPPER(Institution) LIKE UPPER (%'[Edit1.text]'%) OR UPPER(Teilprojekt) LIKE UPPER (%'[Edit1.text)]'%) ');
{hier krieg ich beim kompilieren die Nachricht: Inkompatible Typen: 'Integer' und 'TCAption'}

so:
Query1.Sql.Add('Select * From Table1 WHERE UPPER(Institution) LIKE UPPER ('%[Edit1.text]%') OR UPPER(Teilprojekt) LIKE UPPER ('%[Edit1.text]%') ');
{hier krieg ich beim kompilieren die Nachricht: Ungültiges Zeichen in Eingabedatei:'%'($25)}

und so probiert:
Query1.Sql.Add('Select * From Table1 WHERE UPPER(Institution) LIKE UPPER ('%[+QuotedStr(Edit1.text)+]%') OR UPPER(Teilprojekt) LIKE UPPER ('%[+QuotedStr(Edit1.text)+]%') ');
{das selbe in grün!}

Aber es funkzt nicht!
Weitere Vorschläge?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Fr 19.11.04 20:09 
das in den Klammern war eher so gemeint:'UPPER('+QuotedStr('%'+Edit1.text+'%')+')'

also Pseudocode

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
SadPa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 28

Win 2000; Win XP
D7 Entp
BeitragVerfasst: Do 25.11.04 12:11 
Funktioniert!
Nochmal Danke!