DESCRIBE doesnt work with UniCode
Posted: Thu 10 Apr 2008 15:45
Hi
I'm using Delphi 2006, MyDac 4.40.25, MySQL 4.1.20, my database is in UTF8 coding. In my app I am using DevExpress components to display and work with data. I have had problems corectly display Slovak characters in the grid/editors. Only one solution worked for me and that's setting of TMyConnection.Options.UseUnicode to True. Ok, but then I've got problem fetching results from DESCRIBE command from MySQL using TMyQuery. I've got enum('None',' instead of enum('None','Poor','Good','Excellent').
Here is MySQl table:
CREATE TABLE `customers` (
`CustomerID` INTEGER(11) NOT NULL AUTO_INCREMENT,
`CustomerName` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
`WebSiteQuality` ENUM('None','Poor','Good','Excellent') DEFAULT 'None',
PRIMARY KEY (`CustomerID`)
)ENGINE=InnoDB COMMENT='InnoDB free: 80896 kB' CHECKSUM=0 DELAY_KEY_WRITE=0 PACK_KEYS=0 MIN_ROWS=0 MAX_ROWS=0 ROW_FORMAT=DYNAMIC CHARACTER SET 'utf8'
COLLATE 'utf8_general_ci' INSERT_METHOD=NO;
COMMIT;
Here is the delphi code:
procedure TfrmMain.bGetEnumValuesClick(Sender: TObject);
var
Query: TMyQuery;
begin
Query := TMyQuery.Create(nil);
try
Query.Connection := MyConnection;
Query.SQL.Text := ' DESCRIBE `customers` '+QuotedStr('WebSiteQuality');
Query.Open;
eEnumValues.Text := Query.Fields[1].AsString;
Query.Close;
finally
Query.Free;
end;
end;
If I set TMyConnection.Options.UseUnicode := False, Query.Fields[1].AsString returns what expected.
Can any one help, please?
Thanks
Pavel
I'm using Delphi 2006, MyDac 4.40.25, MySQL 4.1.20, my database is in UTF8 coding. In my app I am using DevExpress components to display and work with data. I have had problems corectly display Slovak characters in the grid/editors. Only one solution worked for me and that's setting of TMyConnection.Options.UseUnicode to True. Ok, but then I've got problem fetching results from DESCRIBE command from MySQL using TMyQuery. I've got enum('None',' instead of enum('None','Poor','Good','Excellent').
Here is MySQl table:
CREATE TABLE `customers` (
`CustomerID` INTEGER(11) NOT NULL AUTO_INCREMENT,
`CustomerName` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
`WebSiteQuality` ENUM('None','Poor','Good','Excellent') DEFAULT 'None',
PRIMARY KEY (`CustomerID`)
)ENGINE=InnoDB COMMENT='InnoDB free: 80896 kB' CHECKSUM=0 DELAY_KEY_WRITE=0 PACK_KEYS=0 MIN_ROWS=0 MAX_ROWS=0 ROW_FORMAT=DYNAMIC CHARACTER SET 'utf8'
COLLATE 'utf8_general_ci' INSERT_METHOD=NO;
COMMIT;
Here is the delphi code:
procedure TfrmMain.bGetEnumValuesClick(Sender: TObject);
var
Query: TMyQuery;
begin
Query := TMyQuery.Create(nil);
try
Query.Connection := MyConnection;
Query.SQL.Text := ' DESCRIBE `customers` '+QuotedStr('WebSiteQuality');
Query.Open;
eEnumValues.Text := Query.Fields[1].AsString;
Query.Close;
finally
Query.Free;
end;
end;
If I set TMyConnection.Options.UseUnicode := False, Query.Fields[1].AsString returns what expected.
Can any one help, please?
Thanks
Pavel