Einzelnen Beitrag anzeigen

akio87

Registriert seit: 18. Mär 2010
44 Beiträge
 
Delphi XE8 Architect
 
#1

MySQL Query Update funktioniert nicht

  Alt 28. Okt 2015, 17:27
Datenbank: MySQL • Version: 5 • Zugriff über: ??
Hallo,

ich habe festgestellt, dass meine alte Update Funktion, siehe 2. Code, in der BDGrid mit einem Leerem String nicht funktioniert. In der neuen Variante, wo ich dachte, das es dort geht, funktioniert der leere String ebenfalls nicht + Update generell nicht, mit folgender Fehlermeldung:
Error: SQL Syntax...

Habt ihr eine Idee?

NEU:
Code:
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Clear;
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('update `' + Tabelle + '`');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('set ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Firma = :Firma, ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Adress1 = :Adress1, ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Adress2 = :Adress2, ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Straße = :Straße, ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('PLZ = :PLZ, ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Ort = :Ort, ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Land = :Land, ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Such1 = :Such1 ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Such2 = :Such2 ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('where ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Firma = :OLD_Firma and ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Adress1 = :OLD_Adress1 and ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Adress2 = :OLD_Adress2 and ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Straße = :OLD_Straße and ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('PLZ = :OLD_PLZ and ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Ort = :OLD_Ort and ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Land = :OLD_Land and ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Such1 = :OLD_Such1 and ');
  MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Add('Such2 = :OLD_Such2;');

Mein Alter Code: Da ging die Update Funktion. Bis auf einem Leeren String....
Code:
{MainModule.UniMainModule.mySQLUpdateSQL1.ModifySQL.Text := 'update ' + Tabelle + #10 +
                                                            'set' + #10 +
                                                            ' Firma = :Firma,'+ #10 +
                                                            ' Adress1 = :Adress1,'+ #10 +
                                                            ' Adress2 = :Adress2,'+ #10 +
                                                            ' Straße = :Straße,'+ #10 +
                                                            ' PLZ = :PLZ,'+ #10 +
                                                            ' Ort = :Ort,'+ #10 +
                                                            ' Land = :Land,'+ #10 +
                                                            ' Such1 = :Such1,'+ #10 +
                                                            ' Such2 = :Such2'+ #10 +
                                                            'where'+ #10 +
                                                            ' Firma = :OLD_Firma and'+ #10 +
                                                            ' Adress1 = :OLD_Adress1 and'+ #10 +
                                                            ' Adress2 = :OLD_Adress2 and'+ #10 +
                                                            ' Straße = :OLD_Straße and'+ #10 +
                                                            ' PLZ = :OLD_PLZ and'+ #10 +
                                                            ' Ort = :OLD_Ort and'+ #10 +
                                                            ' Land = :OLD_Land and'+ #10 +
                                                            ' Such1 = :OLD_Such1 and'+ #10 +
                                                            ' Such2 = :OLD_Such2';
 }
  Mit Zitat antworten Zitat