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

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

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

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

Postby Kosvalery » 04.04.2012, 10:00

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 Dev Team
Zeos Dev Team
Posts: 1739
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 04.04.2012, 18:14

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
King regards, Michael

You want to help? 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

Postby Kosvalery » 05.04.2012, 08:59

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 Dev Team
Zeos Dev Team
Posts: 1739
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 05.04.2012, 17:56

: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
King regards, Michael

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

Image


Return to “MySQL”

Who is online

Users browsing this forum: No registered users and 1 guest