Page 1 of 1

unicode char in Embedded example

Posted: Thu 06 Aug 2009 05:27
by vga
MyConnection.Options
charset : gbk
useunicode: true

test databse : gbk
field: char(10), gbk
mydac: 5.8.047
delphi : 2009
os: win xp

in the example, entry chinese char "", post, refresh, it will become to "?"

Posted: Thu 06 Aug 2009 07:28
by Dimon
To solve the problem try to set the Charset option to gbk and the UseUnicode option to False.

Posted: Fri 07 Aug 2009 07:30
by vga
Dimon wrote:To solve the problem try to set the Charset option to gbk and the UseUnicode option to False.
thank you.

but when I do this, I can not see anything.

Posted: Fri 07 Aug 2009 08:43
by Dimon
I can not reproduce the problem.
Please send me a complete small sample to dmitryg*devart*com to demonstrate it, including a script to create and fill table.

Posted: Sat 08 Aug 2009 00:06
by vga
Dimon wrote:I can not reproduce the problem.
Please send me a complete small sample to dmitryg*devart*com to demonstrate it, including a script to create and fill table.
thank you.

I have send a program to you.

script to create table:
CREATE TABLE `state` (
`PIC_ID` int(11) unsigned NOT NULL auto_increment,
`TYPER1` char(5) NOT NULL default '',
`TYPER2` char(5) NOT NULL default '',
`TYPER3` char(5) NOT NULL default '',
PRIMARY KEY (`PIC_ID`)
) ENGINE=MyISAM AUTO_INCREMENT=100001 DEFAULT CHARSET=gbk ROW_FORMAT=FIXED;
// insert
procedure TfmMain.btn3Click(Sender: TObject);
var
qry: TMyQuery;
begin
qry := TMyQuery.Create(nil);
qry.Connection := MyConnection;

qry.SQL.Text :=
'insert into `state` (`typer1`) values ('''');' +
'insert into `state` (`typer1`) values (''錦錦'');' +
'insert into `state` (`typer1`) values (''錦'');';
qry.Execute;
qry.Free;
DBGrid.DataSource.DataSet.Refresh;
end;


// update
procedure TfmMain.btn1Click(Sender: TObject);
var
qry: TMyQuery;
begin
qry := TMyQuery.Create(nil);
qry.Connection := MyConnection;

qry.SQL.Text := 'update `state` set `typer1`=''''';
qry.Execute;
qry.Free;
DBGrid.DataSource.DataSet.Refresh;
end;


In my Embedded program, neighter insert nor update work well.

Posted: Mon 10 Aug 2009 11:29
by Dimon
To solve the problem you should change font for all data control components on supporting this Unicode char. For example you can use the Tahoma font.

Posted: Mon 10 Aug 2009 22:47
by vga
Dimon wrote:To solve the problem you should change font for all data control components on supporting this Unicode char. For example you can use the Tahoma font.
but the same program work well when I run with mysql server version.
it does not work well with the embeded version!

**************************************
the insert button & update button cannot work!
**************************************

Posted: Tue 11 Aug 2009 10:32
by Dimon
In the example you've sent to us the problem was that the chosen font can not display this symbol.
Please make sure that the Charset option is set to gbk, the UseUnicode option is set to False, and the font is Tahoma.
Also specify the code page used on your machine.

Posted: Wed 12 Aug 2009 00:11
by vga
Dimon wrote:In the example you've sent to us the problem was that the chosen font can not display this symbol.
Please make sure that the Charset option is set to gbk, the UseUnicode option is set to False, and the font is Tahoma.
Also specify the code page used on your machine.
thank you.
now the update button and the insert button did work,
but i cannot see the char "" still.

my code:


unit Main;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DBCtrls, ExtCtrls, Grids, DBGrids, StdCtrls, ToolWin, ComCtrls, Buttons,

DBAccess, MyAccess, Db, MemDS, MyDacVcl, MyCall, MyClasses, MyScript,
MyEmbConnection, DAScript;

type
TfmMain = class(TForm)
DBGrid: TDBGrid;
DataSource: TDataSource;
ToolBar: TPanel;
StatusBar: TStatusBar;
MyTable: TMyTable;
MyScript: TMyScript;
MyConnection: TMyEmbConnection;
Memo1: TMemo;
Panel1: TPanel;
btClose: TSpeedButton;
btOpen: TSpeedButton;
DBNavigator: TDBNavigator;
btn1: TButton;
btn2: TButton;
btn3: TButton;
procedure btOpenClick(Sender: TObject);
procedure btCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure MyConnectionLog(const Text: String);
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure MyConnectionAfterConnect(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
private
{ Private declarations }
procedure ShowState;
public
{ Public declarations }
end;

var
fmMain: TfmMain;


implementation

{$R *.dfm}

procedure TfmMain.ShowState;
var
St: string;

procedure AddSt(S:string);
begin
if St '' then
St := St + ', ';
St := St + S;
end;

begin
St := '';

if MyTable.Active then
AddSt('Active')
else
AddSt('Inactive');

StatusBar.Panels[0].Text := St;
end;

procedure TfmMain.btn1Click(Sender: TObject);
var
qry: TMyQuery;
begin
qry := TMyQuery.Create(nil);
qry.Connection := MyConnection;

qry.SQL.Text := 'update `state` set `typer1`=''''';
qry.Execute;
qry.Free;
DBGrid.DataSource.DataSet.Refresh;
end;

procedure TfmMain.btOpenClick(Sender: TObject);
procedure CreateDatabaseStruct;
begin
MyConnection.Open;
MyScript.Execute;
MyConnection.Database := 'test';
MyTable.Open;
end;

begin
try
try
CreateDatabaseStruct;
MyTable.Open;
except
on E: EMyError do
begin
if E.ErrorCode = ER_NO_SUCH_TABLE then
begin
CreateDatabaseStruct;
MyTable.Open;
end
else raise;
end;
end;

finally
ShowState;
end;
end;

procedure TfmMain.btCloseClick(Sender: TObject);
begin
MyTable.Close;
ShowState;
end;

procedure TfmMain.FormCreate(Sender: TObject);
begin
MyConnection.Options.Charset := 'GBK';
DBGrid.Font.Name := 'Tahoma';

CreateDir('.\data');
CreateDir('.\data\Test');
end;

procedure TfmMain.FormShow(Sender: TObject);
begin
ShowState;
end;

procedure TfmMain.MyConnectionAfterConnect(Sender: TObject);
begin
// MyConnection.ExecSQL('set names gbk;', []);
end;

procedure TfmMain.MyConnectionLog(const Text: string);
begin
if Memo1 nil then
Memo1.Lines.Add(Text);
end;

procedure TfmMain.btn2Click(Sender: TObject);
begin
MyConnection.ExecSQL('truncate table `state`;', []);

DBGrid.DataSource.DataSet.Refresh;
end;

procedure TfmMain.btn3Click(Sender: TObject);
var
qry: TMyQuery;
begin
qry := TMyQuery.Create(nil);
qry.Connection := MyConnection;

qry.SQL.Text :=
'insert into `state` (`typer1`) values ('''');' +
'insert into `state` (`typer1`) values (''錦錦'');' +
'insert into `state` (`typer1`) values (''錦'');';
qry.Execute;
qry.Free;
DBGrid.DataSource.DataSet.Refresh;
end;

end.


It still could not display de char "", and ''錦錦''->''錦"
after press "update" button ( 'update `state` set `typer1`='''''; )
the value of the 3 records field typer1 became nothing.

Posted: Tue 25 Aug 2009 04:05
by vga
It still could not display de char "", and ''錦錦''->''錦"

after press "update" button ( 'update `state` set `typer1`='''''; )
the value of the 3 records field typer1 became nothing.

Posted: Wed 26 Aug 2009 07:14
by Dimon
Please send me a complete small sample to dmitryg*devart*com to demonstrate the problem.
Also specify the code page used on your machine.

Posted: Thu 27 Aug 2009 04:17
by vga
Dimon wrote:Please send me a complete small sample to dmitryg*devart*com to demonstrate the problem.
Also specify the code page used on your machine.
a complete small sample to demonstrate the problem has been sent to
dmitryg*devart*com .

I can entry the character in my windows xp system and display well in nodpad .

Posted: Fri 28 Aug 2009 06:03
by Dimon
Thank you for information. We have reproduced this problem.
This probelm is connected with a bug in some versions of MySQL Embedded server, but not with MyDAC. To solve this problem use another version of MySQL Embedded server, for example version 5.1.22.

Posted: Fri 28 Aug 2009 08:58
by vga
thank you!

with MySQL Embedded server 5.1.22, my program work well now.