Pb with MyDAC5 + Dephi 2007 Pro (GBK)

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
vga
Posts: 58
Joined: Sat 08 Jul 2006 12:04

Pb with MyDAC5 + Dephi 2007 Pro (GBK)

Post by vga » Fri 06 Apr 2007 10:34

My DB:
CREATE DATABASE `test`
My Table:
CREATE TABLE `test` (
`id` int(11) NOT NULL auto_increment,
`Name` char(50) default NULL,
`Date` date default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=gbk;


My Code:
procedure TForm1.FormCreate(Sender: TObject);
begin
MyConnection1.Connected := true;
MyTable1.Active := true;
end;

procedure TForm1.MyConnection1AfterDisconnect(Sender: TObject);
begin
MyQuery1.SQL.Text := 'set names gbk';
MyQuery1.Execute;
end;

when I enter GBK chars Error occured, what should I do?

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

Post by vga » Fri 06 Apr 2007 10:57

delete the followings code:

procedure TForm1.MyConnection1AfterDisconnect(Sender: TObject);
begin
MyQuery1.SQL.Text := 'set names gbk';
MyQuery1.Execute;
end;

It will be fine!


How to make the DBExpress Work with GBK (MySQL Database 5 )?

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

Post by Antaeus » Fri 06 Apr 2007 13:20

To set a character set for the current connection, you should use the Charset options of TMyConnection.

> How to make the DBExpress Work with GBK (MySQL Database 5 )?
If you are using DbxMda, the extended driver option Charset will be useful for you. See description of the extended driver options in the ReadMe.html of DbxMda.

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

Post by vga » Sat 07 Apr 2007 03:23

Thank you, use the Charset options of TMyConnection. It's OK

thanks a lot.

Post Reply