Problems on reading MySQL TEXT fields in Unicode

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for MySQL in Delphi and C++Builder
Post Reply
DmitriNL
Posts: 15
Joined: Fri 26 Nov 2010 15:47

Problems on reading MySQL TEXT fields in Unicode

Post by DmitriNL » Fri 26 Nov 2010 18:39

I'm trying to connect and retrieve Unicode data from a MySQL database. Reading Unicode text from a TEXT field shows wrong characters.

I'm using Windows 7, C++ Builder XE, dbExpress (XE package), MySQL 4.1.18-nt on a webserver and MySQL 5.1.53-community local.

The following parameters are set:

Code: Select all

SQLConnection1->DriverName = "MySQL";
SQLConnection1->GetDriverFunc = "getSQLDriverMYSQL";
SQLConnection1->LibraryName = "dbxmys.dll";
SQLConnection1->VendorLib = "libmysql.dll";
SQLConnection1->Params->Clear();
SQLConnection1->Params->Add("DriverName=MySQL");
SQLConnection1->Params->Add("HostName=domain.net");
SQLConnection1->Params->Add("Database=***");
SQLConnection1->Params->Add("User_Name=***");
SQLConnection1->Params->Add("Password=***");
SQLConnection1->Params->Add("Port=3306");
SQLConnection1->Params->Add("BlobSize=-1");
SQLConnection1->Params->Add("ErrorResourceFile=");
SQLConnection1->Params->Add("LocaleCode=0000");
SQLConnection1->Params->Add("Compressed=False");
SQLConnection1->Params->Add("Encrypted=False");
SQLConnection1->Params->Add("ConnectTimeout=60");
SQLConnection1->Params->Add("ServerCharSet=utf8");
SQLConnection1->LoginPrompt = false;
SQLDataSet1->GetMetadata = false;
Reading from a VARCHAR field works excellent but reading from a TEXT field shows Chinese characters while the content is in Japanese.

I'm using the following code for reading:

Code: Select all

SQLDataSet1->Close();
SQLDataSet1->CommandText = "SELECT * FROM table";
SQLDataSet1->ExecSQL(true);
SQLDataSet1->Open();
SQLDataSet1->First();
Memo1->Clear();
while(!SQLDataSet1->Eof)
{
  Memo1->Lines->Add(SQLDataSet1->FieldByName("field")->AsString); 
  SQLDataSet1->Next();
}
SQLDataSet1->Close();
Writing to the database works when I set 'ServerCharSet=utf8' in the TSQLConnection parameters. Is there maybe a property I missed for reading TEXT fields?

I'm using the following code for writing:

Code: Select all

SQLDataSet1->Close();
SQLDataSet1->CommandText = L"INSERT INTO table ("field") VALUES ('エンバカデロ・テクノロジーズは');";
SQLDataSet1->ExecSQL(true);
SQLDataSet1->Close();
Does someone has an idea how the read TEXT fields in Unicode? Thank you in advance for your help.

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

Post by Dimon » Tue 30 Nov 2010 08:12

To solve the problem try using the Direct mode to connect to MySQL database. For this you should set the TSQLConnection.DriverName property to 'DevartMySQLDirect' and the TSQLConnection.GetDriverFunc property to 'getSQLDriverMySQLDirect' value.

DmitriNL
Posts: 15
Joined: Fri 26 Nov 2010 15:47

Post by DmitriNL » Tue 30 Nov 2010 16:56

After changing the property settings, I receive the error message: Project Project1.exe raised exception class TDBXError with message 'Unknown driver: DevartMySQLDirect'.

I'm using C++ Builder XE Enterprise which contains a dbExpress package. I didn't buy a standalone license. Can I download the missing DLL / library or do I need to buy an upgrade?

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

Post by Dimon » Fri 03 Dec 2010 08:50

To solve the problem add a link to the DbxDevartMySql unit, like this:

Code: Select all

#pragma package(smart_init) 
#pragma link "DbxDevartMySQL" 

DmitriNL
Posts: 15
Joined: Fri 26 Nov 2010 15:47

Post by DmitriNL » Sat 04 Dec 2010 10:13

I've also tried your solutions but there is no file 'DbxDevartMySQL.xxx' or 'DbxDevart*.xxx' on my computer. Im using dbExpress delivered with C++ Builder XE.

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

Post by Dimon » Mon 06 Dec 2010 09:05

To use Devart dbExpress driver for MySQL you should install it. You can download it using the following link: http://www.devart.com/dbx/mysql/download.html

DmitriNL
Posts: 15
Joined: Fri 26 Nov 2010 15:47

Post by DmitriNL » Tue 07 Dec 2010 07:40

This is not a long term solution. Your download is a trial. The dbExpress in C++ Builder should work properly otherwise this component is useless.

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

Post by Dimon » Tue 07 Dec 2010 13:55

We don't support standard dbExpress drivers. You can buy DbxMda here: http://www.devart.com/dbx/mysql/ordering.html

DmitriNL
Posts: 15
Joined: Fri 26 Nov 2010 15:47

Post by DmitriNL » Thu 09 Dec 2010 08:52

Still this is not a proper solution. I'm disappointed. :(

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

Post by Dimon » Thu 09 Dec 2010 11:12

DbxMda provides a driver as an independent library that implements the common dbExpress interface for processing queries and stored procedures. DbxMda driver provides direct access to MySQL database server based on Borland dbExpress data access technology. It can work using MySQL client or native MySQL network protocol, that provides higher performance of direct access to server data without using the client dll library.

Post Reply