Page 1 of 1

Problem with tinyint

Posted: Sat 25 Mar 2006 18:01
by WarForge00
Here's the database that I'm using...

CREATE TABLE `users` (
`userID` bigint(20) unsigned NOT NULL auto_increment,
`username` varchar(32) NOT NULL default '',
`password` varchar(32) NOT NULL default '',
`name` varchar(255) NOT NULL default '',
`active` tinyint(1) unsigned NOT NULL default '0',
`accountaccess` tinyint(1) unsigned NOT NULL default '0',
`adminaccess` tinyiny(1) unsigned NOT NULL default '0',
PRIMARY KEY (`userID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=1 ;

INSERT INTO `users` VALUES (1, 'admin', '43e9a4ab75570f5b', 'Administrator', 1, 1, 1);

I have that on a remote MySQL database and an embedded localdatabase with just the table (no data in the local database). If I do the following code:

frmLogin.remoteQuery.SQL.Text := 'SELECT * FROM users';
frmLogin.remoteQuery.Open;
for i := 1 to frmLogin.remoteQuery.RecordCount do
begin
frmLogin.localQuery.SQL.Clear;
frmLogin.localQuery.SQL.Text := 'INSERT INTO users (userID, username, password, name, active, accountaccess, adminaccess) VALUES (' + inttostr(frmLogin.remoteQuery.FieldValues['userID']) + ', ' + QuotedStr(frmLogin.remoteQuery.FieldValues['username']) + ', ' + QuotedStr(frmLogin.remoteQuery.FieldValues['password']) + ', ' + QuotedStr(frmLogin.remoteQuery.FieldValues['name']) + ', ' + inttostr(frmLogin.remoteQuery.FieldValues['active']) + ', ' + inttostr(frmLogin.remoteQuery.FieldValues['accountaccess']) + ', ' + inttostr(frmLogin.remoteQuery.FieldValues['adminaccess']) + ')';
frmLogin.localQuery.Execute;

frmLogin.remoteQuery.Next;
end;

The values of active, accountaccess, and adminaccess all become true instead of 0 or 1.

Posted: Sat 25 Mar 2006 18:02
by WarForge00
Forgot to add the following...

If i change the type from tinyint(1) to int(10), then the values stay as 1 or 0 and don't get changed to true or false.

Posted: Sun 26 Mar 2006 22:16
by GEswin
Tinyint ( 1 ) is represented as boolean in MyDac components. This feature was introduced to use boolean fields together with mysql.

Posted: Mon 27 Mar 2006 07:34
by swierzbicki
In your MyQuery / MyTable option :

EnableBoolean : Specifies a method of representation of TINYINT(1) fields. If set to True these fields will be represented as TBooleanFiled; otherwise, as TSmallintField. The default value is True;