Page 1 of 1

cannot save chinese character

Posted: Tue 01 Oct 2013 16:54
by tracy1080
I try to use Delphi 2007 and dbexpress for Mysql. When I save record with chinese, it shows error.
What I should do ?

Re: cannot save chinese character

Posted: Fri 04 Oct 2013 06:38
by AndreyZ
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.

Re: cannot save chinese character

Posted: Fri 04 Oct 2013 07:32
by tracy1080
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;

Re: cannot save chinese character

Posted: Fri 04 Oct 2013 08:06
by AndreyZ
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.