cannot save chinese character

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for MySQL in Delphi and C++Builder
Post Reply
tracy1080
Posts: 5
Joined: Thu 21 Mar 2013 14:41

cannot save chinese character

Post by tracy1080 » Tue 01 Oct 2013 16:54

I try to use Delphi 2007 and dbexpress for Mysql. When I save record with chinese, it shows error.
What I should do ?

AndreyZ

Re: cannot save chinese character

Post by AndreyZ » Fri 04 Oct 2013 06:38

Please specify the exact error that occurs when you try to save a record.

Also, note that all Delphi versions earlier than Delphi 2009 do not fully support Unicode. Delphi 2009 and higher versions have full Unicode support. If you want to work with Unicode characters (such as Chinese), you should use Delphi 2009 or higher.

tracy1080
Posts: 5
Joined: Thu 21 Mar 2013 14:41

Re: cannot save chinese character

Post by tracy1080 » Fri 04 Oct 2013 07:32

If I run the following code, it will show error and cannot save change. Thanks!
#HY000Incorrect string value:'xEe\xB8\xB3\xE6\x88\xB6' for column 'off_addr' at row 1.

procedure TForm3.Button2Click(Sender: TObject);
var tqry : TSQLQuery;
begin
tqry := TSQLQuery.create(Self);
tqry.SQLConnection := SQLConnection1;
tqry.SQL.Text := 'update customer set off_addr = ''帳戶'' ';
tqry.ExecSQL(False);
tqry.Free;
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
with TSQLConnection(FindComponent('SQLConnection1')) do
begin
Close;
Params.Clear;
Params.Append('Database=INSURANCE');
Params.Append('User_Name=root');
Params.Append('Password=123');
Params.Append('HostName=localhost');
Params.Append('UseUniCode=true');
Params.Append('ServerCharset=utf8');
Open;
end;
end;

AndreyZ

Re: cannot save chinese character

Post by AndreyZ » Fri 04 Oct 2013 08:06

Please specify the following:
- the script to create the customer table;
- the exact version of RAD Studio 2007 you are using, for example, RAD Studio 2007 11.0.2902.10471 ;
- the exact version of dbExpress driver for MySQL you are using;
- your Windows codepage.

Post Reply