Page 1 of 1

Unicode with Delphi 6

Posted: Sun 25 Sep 2005 16:48
by struppy
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

Posted: Mon 26 Sep 2005 11:28
by Ikar
Set property TMyConnection,.Options.UseUnicode to True

Posted: Mon 26 Sep 2005 11:57
by struppy
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

Posted: Tue 27 Sep 2005 09:53
by Ikar
Try to use AsWideString instead of AsVariant

Posted: Tue 27 Sep 2005 11:03
by struppy
There is no function AsWideString

Posted: Wed 28 Sep 2005 09:54
by struppy
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

Posted: Wed 28 Sep 2005 10:42
by Ikar
Try to use

Code: Select all

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

Posted: Wed 28 Sep 2005 11:34
by struppy
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

Posted: Wed 28 Sep 2005 13:45
by struppy
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

Posted: Sat 08 Oct 2005 11:47
by Bernhard Geyer
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.

Posted: Sat 08 Oct 2005 12:31
by GEswin
This bug is fixed in 4.1.14 and 5.1.10