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

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Kosvalery
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 23.03.2012, 08:35

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

Post 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
Last edited by Kosvalery on 05.04.2012, 08:49, edited 1 time in total.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post 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
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Kosvalery
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 23.03.2012, 08:35

Post by Kosvalery »

Great thanks, EgonHugeist!
Your branch is solve my problem. Now working with native for base ClientCodepage cp1251 and UTF8 also working fine.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post 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
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Post Reply