Autor Beitrag
pepsen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Mi 25.10.06 09:48 
moin moin...

wie scho im Titel lesbar hab ich ein Problem mit der Syntax bei einer SQL-Anweisung...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
  auswahl := ComboBoxFG.Text;
  query1.Close;
  query1.SQL.Add('SELECT * FROM Z4MSYS WHERE F1=auswahl'); // FEHLERMELDUNG!!
  query1.Open;

der Fehler kann ja eigentlich nur bei dem WHERE liegen aber ich finde ihn nicht! Hab es auch schon mit Doppel-Hochkomma(soll ja sowieso nicht als string sondern als string-variable gelten), mit einem Hochkomma bei "auswahl" probiert...aber das geht auch nicht!
iKilledKenny
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 8

Win XP
D5 Prof, C# Express 2005
BeitragVerfasst: Mi 25.10.06 09:51 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
auswahl := ComboBoxFG.Text;
sql := Format ('SELECT * FROM Z4MSYS WHERE F1=%s', [QuotedStr (auswahl)]);
query1.Close;
query1.SQL.Add(sql); 
query1.Open;


so sollte es gehen.

grüße
alex
pepsen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Mi 25.10.06 10:01 
hmmm....nee, funzt leider nich! :/

FEHLERMELDUNG:
Ungültiges Schlüsselwort
Symbol-String: SELECT
Zeilennummer: 2

das "sql" muss ich doch als String deklarieren, oder?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 25.10.06 10:06 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
auswahl := ComboBoxFG.Text;
sql := Format ('SELECT * FROM Z4MSYS WHERE F1=%s', [QuotedStr (auswahl)]);
query1.Close;
query1.SQL.Clear; // Nicht vergessen!!!
query1.SQL.Add(sql); 
query1.Open;

Wenn noch was im SQL steht, wird durch das "Add" das neue dran gehängt. Also schön vorher leer machen.
pepsen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Mi 25.10.06 10:14 
fein es funzt...danke dir!

MfG Peter