Autor Beitrag
Ungfmaster
Hält's aus hier
Beiträge: 9


D6 Prof
BeitragVerfasst: Fr 29.10.04 13:52 
Servus,

Ich habe ein kleines problem mit meinen Updateanweisungen die ich an MySQL über ADO schicken will. Ich glaube ganze tritt nur bei strings auf die das Quotes ' unf " für Strings enthalten. Alle meine Strings werden UTF8 codiert an die DB geschickt.

Jetzt mal ein bischen Code von meiner Update-Funktion :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
With ADO.ADOQuery do
begin
     Active := False;
     SQL.Clear;
     SQL.Add('update dictionary set ');
     SQL.Add('editor = '+PreS(TIBPTransFactory.GetInstance.getEditor)+',');
     SQL.Add('datestamp = now() ,');
     SQL.Add('word = '+PreS(UTF8Encode(data.S))+' where ');
     SQL.Add('dicid = '+IntToStr(data.ID1)+' AND ');
     SQL.Add('lanid = '+IntToStr(data.ID2));
     ExecSQL;
end;


data ist ein record mit S = WideString; ID1,ID2 sind Integer.
Der Fehler tritt glaube ich bei dem Parameter für 'word' auf.

PreS sieht so aus :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function TransMySQLDB.PreS(s: WideString): WideString;
begin
     // brauch ich um \ in Strings haben zu können
     s := StringReplace(s,'\','\\',[rfReplaceAll]); 
     Result := QuotedStr(s);
end;


Da \ das Escapezeichen ist dache ich ich könnte mit \" das ganze umgehen, hilft aber auch nix.

Das ganze geht wunderbar bis eben auf die Strings die mit ' gequoted sind und " enthalten und nun in die DB geschrieben werden sollen wie z.B. : 'die Sperre aufheben ("Ergebnisse : Letzer Rechenlauf").'


Als Meldung bekomme ich dann immer eine EOleException, Meldung : Ein Parameterobjekt ist nicht ordnungsgemäß definiert. Inkonsitente oder unvollständige Informationen wurden angegeben.

Vielen Dank schonmal im voraus.

_________________
Ein Cocktail ohne Alkohol ist kein Cocktail
MarkusB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Sa 30.10.04 13:40 
Moin Ungfmaster!

Ungfmaster hat folgendes geschrieben:

SQL.Clear;
SQL.Add('update dictionary set ');
SQL.Add('editor = '+PreS(TIBPTransFactory.GetInstance.getEditor)+',');
SQL.Add('datestamp = now() ,');
SQL.Add('word = '+PreS(UTF8Encode(data.S))+' where ');
SQL.Add('dicid = '+IntToStr(data.ID1)+' AND ');
SQL.Add('lanid = '+IntToStr(data.ID2));
ExecSQL;



Ist das Wort "word" als Feldname zulässig?

Viele Grüße
Markus
:?!?:
Ungfmaster Threadstarter
Hält's aus hier
Beiträge: 9


D6 Prof
BeitragVerfasst: Sa 30.10.04 14:27 
Servus MarkusB,
Ja ist 'word' als Feldname ist erlaubt.
Es funktioniert ja auch in 99,9% der Fälle

_________________
Ein Cocktail ohne Alkohol ist kein Cocktail
MarkusB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Sa 30.10.04 15:25 
Moin Ungfmaster!

Ungfmaster hat folgendes geschrieben:

SQL.Clear;
SQL.Add('update dictionary set ');
SQL.Add('editor = '+PreS(TIBPTransFactory.GetInstance.getEditor)+',');
SQL.Add('datestamp = now() ,');
SQL.Add('word = '+PreS(UTF8Encode(data.S))+' where ');
SQL.Add('dicid = '+IntToStr(data.ID1)+' AND ');
SQL.Add('lanid = '+IntToStr(data.ID2));
ExecSQL;



Kennt MySQL die Funktion now()?

Viele Grüße
Markus
:?!?:
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Mo 01.11.04 09:13 
Ja.
Word ist nicht zwangsläufig erlaubt. Setz es besser in "´" und probiers dann nochmal.

Und alel Strings an mySQL mit "'" einklammern.

Viele Grüße,

Matthias

_________________
Ha! Es compiliert! Wir können ausliefern!