Page 1 of 1

Character Set MySQL "set names"

Posted: Tue 22 May 2007 14:01
by uKlarmann
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

Posted: Wed 23 May 2007 12:05
by Antaeus
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.

Sorry, Didn't solve the problem

Posted: Thu 24 May 2007 10:10
by uKlarmann
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.

Posted: Fri 25 May 2007 11:21
by Antaeus
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).