Unicode with Delphi 6

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
struppy
Posts: 6
Joined: Fri 23 Sep 2005 08:50

Unicode with Delphi 6

Post by struppy » Sun 25 Sep 2005 16:48

Hi

i 'm looking in the forum for an answer but cannot find one

my probelm is, i see my unicode text in the database (mysdql 4..) but i can 't read (select) them , i always see only '???????????'

to insert the unicode text i use params.

I use the latest build of mydac.

her some code:

login options:

LoginPrompt := false;
Server := pm_Server;
Database := pm_DB;
Password := aPasswort;
Username := aUser;
Port := 3306;
Connected:=TRUE;
Options.UseUnicode := True;

database:

CREATE TABLE `example` (
`Id` int(11) NOT NULL auto_increment,
`BEZ` text,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

`BEZ` is the field for the unicode text

Thank you in advance and
best regards

struppy

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 26 Sep 2005 11:28

Set property TMyConnection,.Options.UseUnicode to True

struppy
Posts: 6
Joined: Fri 23 Sep 2005 08:50

Post by struppy » Mon 26 Sep 2005 11:57

hallo Ikar,

the property TMyConnection.Options.UseUnicode is set to true

I use a normal select statment like

select * from tabel

and then

Bez:Widestring;

Bez := Query.FieldByName('BEZ').AsVariant;

but bez is always '????????' for unicode chars in the db

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 27 Sep 2005 09:53

Try to use AsWideString instead of AsVariant

struppy
Posts: 6
Joined: Fri 23 Sep 2005 08:50

Post by struppy » Tue 27 Sep 2005 11:03

There is no function AsWideString

struppy
Posts: 6
Joined: Fri 23 Sep 2005 08:50

Post by struppy » Wed 28 Sep 2005 09:54

If i use varchar(255) as field typ in the db it works fine.

but 255 chars are not enough for my application.

Now is it a problem of mydac or of mysql-server?

best regards

struppy

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Wed 28 Sep 2005 10:42

Try to use

Code: Select all

Assert(Query.FieldByName('BEZ') is TWideStringField);
Bez := TWideStringField(Query.FieldByName('BEZ')).Value;

struppy
Posts: 6
Joined: Fri 23 Sep 2005 08:50

Post by struppy » Wed 28 Sep 2005 11:34

same as before it works only with varchar typ.

if i use text-typ or something else i don't get a TWideStringField

i try it with all other typs only varchar is working fine.

i don't understand whey the insert and update with params works with all field typs

struppy

struppy
Posts: 6
Joined: Fri 23 Sep 2005 08:50

Post by struppy » Wed 28 Sep 2005 13:45

blob := Query.GetBlob('BEZ');
Bez := blob.AsWideString;

the problem was that the fieldtyps Text,Mediumtext.. are BLOB's in MYSQL

thank you for your help

struppy

Bernhard Geyer
Posts: 20
Joined: Fri 30 Sep 2005 14:13

Post by Bernhard Geyer » Sat 08 Oct 2005 11:47

struppy wrote:blob := Query.GetBlob('BEZ');
Bez := blob.AsWideString;

the problem was that the fieldtyps Text,Mediumtext.. are BLOB's in MYSQL

thank you for your help

struppy
Do you use MySQL 4.1.14? There is a bug in this MySQL-Version that nvarchar-Field are returned as Blob-Fields.

GEswin
Posts: 186
Joined: Wed 03 Nov 2004 16:57
Location: Spain
Contact:

Post by GEswin » Sat 08 Oct 2005 12:31

This bug is fixed in 4.1.14 and 5.1.10

Post Reply