Autor Beitrag
bvl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Do 08.12.05 12:11 
Hallo, ich habe ne Kleinigkeit geändernt und jetzt bringen mir die folgenden Zeilen
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
  if Query.Active then Query.Close;
  Query.SQL.Clear;
  Query.SQL.Add ('UDPATE rel_employees ');
  Query.SQL.Add ('SET firstname = ' + quotedstr(trim(FirstName))+', ');
  Query.SQL.Add ('MiddleNames = ' + quotedStr(trim(MiddleNames)) + ', ');
  Query.SQL.Add ('SurName = ' + quotedStr(trim(SurName)) + ', ');
  Query.SQL.Add ('Active = ' + quotedStr(inttostr(BooleanToInt(Active))));
  Query.SQL.Add ('WHERE id = '+quotedstr('1'));
  ShowMessage ('Test-Updating the Database: '+Query.SQL.Text);
  Query.ExecSQL;


die Fehlermeldung "...EOleException mit der Meldung 'Zeile 2: Falsche Syntax in der Nähe von '='' aufgetreten."

???????????? RAAAAATLOOOOOOOOS ??????????

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 08.12.05 12:17 
Auf den ersten Blick sehe ich nichts was falsch ist. Hast du alle Feldnamen richtig geschrieben?
Warum benutzt du eigentlich keine Parameter? Das macht meiner Meinung nach den Code übersichtlicher und ist effizienter, wenn du eine Abfrage mehrfach ausführen musst.

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
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: Do 08.12.05 12:20 
Ich kann mir nur vorstellen, dass das QuotedStr bei "ID" in der Wehre-Klausel falsch ist. Eine ID ist normalerweise numerisch.
Aber das steht nicht in Zeile 2 des Statements. :gruebel:
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 08.12.05 12:25 
user profile iconjasocul hat folgendes geschrieben:
Ich kann mir nur vorstellen, dass das QuotedStr bei "ID" in der Wehre-Klausel falsch ist. Eine ID ist normalerweise numerisch.
Aber das steht nicht in Zeile 2 des Statements. :gruebel:


Oracle würde versuchen, das zu konvertieren. Andere DBs könnten da pingeliger sein - bvl hat leider nicht geschrieben, was er verwendet...

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
bvl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Do 08.12.05 12:26 
Mit

Query.SQL.Add ('WHERE id = 1');

am Ende gibt es die gleiche Fehlermeldung...

Was ist mit den Parametern gemeint? Hast du ein Beispiel?
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 08.12.05 12:38 
Sowas wie:

ausblenden SQL-Anweisung
1:
2:
3:
4:
5:
6:
UPDATE rel_employees
   SET FirstName = :firstname,
       MiddleNames = :middlenames,
       SurName = :surname,
       active = :active,
 WHERE id = :id


Die Parameterwerte kannst du dann mit

ausblenden Delphi-Quelltext
1:
Query.ParamByName('firstname').AsString = firstName;					


setzen. Die Syntax gilt für die BDE, wenn du was anderes verwendest, kann die Syntax etwas anders aussehen.

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Do 08.12.05 12:49 
Vor dem WHERE fehlt das Leerzeichen, wenn ich das richtig sehe.
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 08.12.05 12:51 
user profile iconRobert.Wachtel hat folgendes geschrieben:
Vor dem WHERE fehlt das Leerzeichen, wenn ich das richtig sehe.


Query.SQL.Add fügt eine neue Zeile ein, da braucht man nicht noch ein Leerzeichen.

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Do 08.12.05 12:52 
Stimmt, habe ich glatt übersehen ;-
bvl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29



BeitragVerfasst: Do 08.12.05 13:59 
Ich habe den Quelltextteil jetzt mal in ein anderes Proggy ge-copy-pasted. Und da gings. Dann habe ich es wieder zurück-ge-copy-pasted, und es ging immer noch.

Zeichen für Zeichen identischer code!!! Sehr suspekt...
senidex
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

WIN XP

BeitragVerfasst: Do 08.12.05 18:17 
Hallo,
funktioniert es jetzt oder nicht ?
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Fr 09.12.05 03:02 
Ich hatte irgendwann mal das Problem, dass aus dem Browser kopierter Code sich nicht in Delphi kompilieren ließ, aufgrund einer falschen Codierung der Leerstellen. Evtl. war genau dass das Problem. Das Phänomen ist aber schon einige Zeit her und ich weiß nicht mehr genau mit welchem Browser das passierte.