Character Set MySQL "set names"

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
uKlarmann
Posts: 7
Joined: Tue 22 May 2007 13:52

Character Set MySQL "set names"

Post by uKlarmann » Tue 22 May 2007 14:01

MySQL 5.032
Delphi 7
MyDac 4.30.0.10

the character set of mysql server ist utf8, tables and database the same. I switched my Delphi application to utf8 using set names:

MyConnection1.ExecSQL('set names utf8;',[]);

but the German special characters don't show correct and if I try to save a string to the database it gets deleted completely.

what did I do wrong?

Thank you for your help in advance!

Ulf

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 23 May 2007 12:05

You should assign the corresponding character set name to TMyConnection.Options.Charset instead of execution this command, TMyConnection will execute it automatically. If you do this manually, MyDAC is not aware of the current connection character set name.

uKlarmann
Posts: 7
Joined: Tue 22 May 2007 13:52

Sorry, Didn't solve the problem

Post by uKlarmann » Thu 24 May 2007 10:10

Thank you for your answer.
I also tried to set TMyConnection.Options.Charset to utf8 but I had the same problem, the special characters are not shown correctly.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 25 May 2007 11:21

If you use the utf8 character set, you should use DB-aware controls that support utf8 as well, but there are few of such controls on the market.

If you want to work with Unicode, you should set the UseUnicode option of TMyConnection to True, and use DB-aware controls with Unicode support (like TNT controls).

If you want your application to be able to display Latin and German-specific characters only, you should just specify the corresponding character set name in TMyConnection.Options.Charset, and correctly setup Language for non-Unicode programs in your system (see Control Panel -> Regional and Language Options -> Advanced).

Post Reply