Hallo,
bei der Abfrage einer
MySQL Datenbank erscheint folgender Fehler:
SQL Error: You have an error in your SQL syntax near " at line 1.
Was mache ich falsch?
Delphi-Quellcode:
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
LI: TListItem;
q :
string;
begin
q:= '
%' + Edit1.Text + '
%';
with ZReadOnlyQuery1
do
begin
close;
SQL.Clear;
SQL.Add ('
SELECT * FROM Adresse WHERE');
SQL.Add ('
ID LIKE :ID OR ');
SQL.Add ('
Name LIKE :Name OR ');
SQL.Add ('
Vorname LIKE :Vorname OR ');
SQL.Add ('
Adresse LIKE :Adresse OR ');
SQL.Add ('
PLZ LIKE :PLZ OR ');
SQL.Add ('
Stadt LIKE :Stadt OR ');
ParamByName ('
ID').AsString := q;
ParamByName ('
Name').AsString := q;
ParamByName ('
Vorname').AsString := q;
ParamByName ('
Adresse').AsString := q;
ParamByName ('
PLZ').AsString := q;
ParamByName ('
Stadt').AsString := q;
open;
ListView1.Items.BeginUpdate;
Listview1.Items.Clear;
while not (EOF)
do
begin
LI := Listview1.Items.Add;
LI.ImageIndex := 0;
LI.Caption := (FieldByName('
ID').AsString);
LI.SubItems.Add(FieldByName('
Name').AsString);
LI.SubItems.Add(FieldByName('
Vorname').AsString);
LI.SubItems.Add(FieldByName('
Adresse').AsString);
LI.SubItems.Add(FieldByName('
PLZ').AsString);
LI.SubItems.Add(FieldByName('
Stadt').AsString);
Next;
end;
ListView1.Items.EndUpdate;
close;
end;
end;
Danke
Thomas