Page 1 of 1

[SOLVED] ClientCodepage don't apply to Parameters SQL query

Posted: 04.04.2012, 10:00
by Kosvalery
I have MySQL base with cp1251 codepage tables
ZConnection.ClientCodepage: cp1251
If i use

Code: Select all

ZQuery.SQL.Text:='INSERT INTO `testtable` (`name`) VALUES (''сyrillic text Текст'')';
ZQuery.ExecSQL;
then data inserted in correct codapge, but if

Code: Select all

ZQuery.SQL.Text:='INSERT INTO `testtable` (`name`) VALUES (:txtparam)';
ZQuery.Params[0].AsString:='сyrillic text Текст';
ZQuery.ExecSQL;
then data inserted in UTF-8 regardless of the setting ClientCodepage and this method impossible for me. As I understand it this occurs in ZDbcMySqlStatement unit:

Code: Select all

function TZMySQLEmulatedPreparedStatement.GetEscapeString(const Value: string): string;
...
  {$IFDEF DELPHI12_UP}
    BufferLen := FPlainDriver.GetEscapeString(Buffer, PAnsiChar(UTF8Encode(Value)), Length(PAnsiChar(UTF8Encode(Value))))
  else
    BufferLen := FPlainDriver.GetRealEscapeString(FHandle, Buffer, PAnsiChar(UTF8Encode(Value)), Length(PAnsiChar(UTF8Encode(Value))));
...
end;
How to fix it?
Zeos from SVN /trunk, revision 1082
Delphi XE

Posted: 04.04.2012, 18:14
by EgonHugeist
Kosvalery,

Use this one:

http://zeos.firmos.at/viewtopic.php?t=3427

Would you be so kind and spend some testing-time with me?
It would be very helpfull for me if you would test this branch and tell me some problems and expiriences.

best regards

EgonHugeist

Posted: 05.04.2012, 08:59
by Kosvalery
Great thanks, EgonHugeist!
Your branch is solve my problem. Now working with native for base ClientCodepage cp1251 and UTF8 also working fine.

Posted: 05.04.2012, 17:56
by EgonHugeist
:thanks:

Thanks for your reply. Reporting such good news from a XE user would be fine on testing-egonhugeist thread.

Btw. If you set PreprepareSQL := True; than you don't need to encode any string. It doesn't matter if you use native Ansi-CodePages or Unicode. Left them like they are. Everything should be fine ...

:cheers:

Best regards