Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi ZeosDbo - Updatebefehl - Fehler bei WHERE?! (https://www.delphipraxis.net/2884-zeosdbo-updatebefehl-fehler-bei-where.html)

1PM 11. Feb 2003 17:02


ZeosDbo - Updatebefehl - Fehler bei WHERE?!
 
Hallo!

Bekomme eine Fehlermeldung bei WHERE bei folgenden Befehlen:
Delphi-Quellcode:
    id := 1;
    prize1 := strtofloat(txt_0_1.text);
    prize2 := strtofloat(txt_1_1.text);
    prize3 := strtofloat(txt_2_1.text);
    frmmain.qu.SQL.Text:='UPDATE `prize` Set `prize1`=''prize1'','+
                             '`prize2`=''prize2'','+
                             '`prize3`=''prize3'','+
                             'WHERE `id`=''id'';';
    frmmain.qu.ExecSql;
Hat jemand eine Ahnung?
Vielen Dank im voraus!

Gruß 1PM

exakte Fehlermeldung : Project1.exe raised exception class EDatabaseError with message 'qu: You have an error in your SQL syntax near 'WHERE `id`='id'' at line 1'. Process stopped.

phlux 11. Feb 2003 18:38

Hiho

Ich glaube du musst die ` durch ' <-Hochstriche ersetzen in diesem fall musst du doppelte Hochstriche benutzen damit Delphi einen macht

1PM 11. Feb 2003 19:12

Das mit den Strichen ist schon richtig so wie ich es gemacht habe! Wenn ich Updaten will, bringt er mir diese Fehlermeldung!
TRotzdem Danke für deine Hilfe!

Gruß 1PM

ChrisF 12. Feb 2003 14:33

Hallo, ich versuch mich mal.

Zitat:

Delphi-Quellcode:
frmmain.qu.SQL.Text:='UPDATE `prize` Set `prize1`=''prize1'','+
                             '`prize2`=''prize2'','+
                             '`prize3`=''prize3''[b],[/b]'+
                             'WHERE `id`=''id'';';

1. Die Fehlermeldung dürfte durch das ',' (also Komma ohne Hochkommata) vor dem WHERE kommen.
2. So wie du das schreibst setzt er die prize-Felder auf den String 'prize1' etc.
Könntest du vielleicht folgendes wollen:


Delphi-Quellcode:
  id := 1;
  prize1 := strtofloat(txt_0_1.text);
  prize2 := strtofloat(txt_1_1.text);
  prize3 := strtofloat(txt_2_1.text);
  frmmain.qu.SQL.Text:='UPDATE prize Set '+
     'prize1 ='+FormatFloat('0,00', prize1)+
    ', prize2 ='+FormatFloat('0,00', prize2)+
    ', prize3 ='+FormatFloat('0,00', prize3)+
    ' WHERE id='IntToStr(id);
  frmmain.qu.ExecSql;
Chris

1PM 19. Feb 2003 16:56

Vielen Dank Chris! Hat super funktioniert! :hello: :hello: :hello:


Gruß 1PM


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:26 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz