unicode in SQL-query results

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
cyrilo
Posts: 18
Joined: Wed 11 Oct 2006 08:47

unicode in SQL-query results

Post by cyrilo » Thu 21 Feb 2008 17:48

Hello!
My console application get data from SQL query by this two ways:

Code: Select all

dummy := SQL1.FieldByName('Name').AsString;
or

Code: Select all

dummy := SQL1.Fields[0].AsString;
Offcause, MySQL connection procedure contained

Code: Select all

Options.UseUnicode:=true;
In my case query result is Unicode. But .AsString is incompatible with unicode. I can't use .AsWideString instead of .AsString - I got error from compiler.
Can anyone help me with resolution of problem?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 22 Feb 2008 14:39

You can use the following code:

Code: Select all

dummy := (SQL1.FieldByName('Name') as TWideStringField).Value;

cyrilo
Posts: 18
Joined: Wed 11 Oct 2006 08:47

Post by cyrilo » Sat 23 Feb 2008 00:02

my problem still present
I use following code for insert result of query:

Code: Select all

SQL.Clear;
SQL.Add('INSERT INTO test VALUES');
SQL.Add('("' + (SQL1.FieldByName('Name') as TWideStringField).Value + '")');
And got non-unicode results in database.
Probably I need to use SQL parameters for unicode-data instead of SQL.Add('') construction?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 26 Feb 2008 15:03

As for now TMyQuery does not support direct working with Unicode in SQL, but we will support such functionality in one of the next versions.

vga
Posts: 58
Joined: Sat 08 Jul 2006 12:04

is it can be true soon?

Post by vga » Sat 26 Jul 2008 03:34

:D

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Sat 26 Jul 2008 15:55

Use the UnicodeToUtf8 function?

Post Reply