Page 1 of 1

unicode in SQL-query results

Posted: Thu 21 Feb 2008 17:48
by cyrilo
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?

Posted: Fri 22 Feb 2008 14:39
by Dimon
You can use the following code:

Code: Select all

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

Posted: Sat 23 Feb 2008 00:02
by cyrilo
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?

Posted: Tue 26 Feb 2008 15:03
by Dimon
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.

is it can be true soon?

Posted: Sat 26 Jul 2008 03:34
by vga
:D

Posted: Sat 26 Jul 2008 15:55
by kaffeburk
Use the UnicodeToUtf8 function?