Cannot access field 'XXXX' as type Integer

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
craigmadsen
Posts: 2
Joined: Sun 24 Sep 2006 00:42

Cannot access field 'XXXX' as type Integer

Post by craigmadsen » Sun 24 Sep 2006 02:48

DataModule3.Query1.SQL.Clear;
DataModule3.Query1.SQL.Add( 'SELECT League FROM LEAGUE ');
DataModule3.Query1.Active := TRUE;
if DataModule3.Query1.RecordCount > 0 then begin
DataModule3.Query1.First;
League_No := DataModule3.Query1.Fields[0].AsInteger;
end;

This code used to work just fine, but I've upgraded to Windows XP, and all xxxx broke loose. I've upgraded to MyDAC 4.40 Trial Version (though I own a valid copy of MyDAC -- are there upgrade discounts?), and now I'm getting the following error with above query using a TMyQuery component:

Cannot access field 'League' as type Integer

I'm using MySQL 4.015. I'm using Delphi 7 Professional.

Any help would be greatly appreciated!

Thanks.

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

Post by Antaeus » Mon 25 Sep 2006 11:17

Please specify what type has this field on the server (INT, VARCHAR, etc.) and what class has this field on the client (TIntegerField, TStringField etc.).

craigmadsen
Posts: 2
Joined: Sun 24 Sep 2006 00:42

Post by craigmadsen » Tue 26 Sep 2006 13:22

Please specify what type has this field on the server (INT, VARCHAR, etc.) and what class has this field on the client (TIntegerField, TStringField etc.).

On the MySQL database, that particular field is defined as a TinyInt. When using Navicat MySQL to change this field from a TinyInt to an Int, the program went to the next field that was a TinyInt with the same problem. However, when I try to change this field using the same tool, I'm getting an error (which is not a problem with MyDAC.

So as far as this message/topic is concerned, this issue has been resolved.

Thanks,

Craig

lucasbr
Posts: 5
Joined: Fri 22 Sep 2006 00:12

Post by lucasbr » Tue 26 Sep 2006 18:44

Tinyint(1) fields are treated like boolean type.

Look at OPTIONS at your TMYQUERY component and change ENABLEBOOLEAN to FALSE and your problem will be solved.

Search this forum for TINYINT and you will find more about this
behavior.

Post Reply