I have a dbcheckbox and the changes are not being recorded. I can check and uncheck the box but nothing is stored.
In MySql I tried setting the type to Char(1), Bit, Int(1) and binary. Char and Binary do not cause Delphi to crash. In the fieldkind of Delphi, all MySql fields come through as fkData.
In the object inspector, Delphi seems to know what is TStringField and TIntegerField but there is no where to change this type.
Not sure how to go forward other than writing code.
Thanks Wallace.
dbCheckbox not updating - delphi
Re: dbCheckbox not updating - delphi
To solve your task, you can use the system type tinyint(1). For example:
When working with MySQL, UniDAC creates a TBooleanField for these fields.
Also you can use Data Type Mapping for fields of the system type Bit. Before connecting, you can set the following rule Data Type Mapping:
This rule will be applied to the data of the system type Bit. To use constants myBit you need to add MyDataTypeMap unit in the uses section.
Also, you can map data of the system type Bit using the 'Field Name' of the needed columns:
Code: Select all
BoolField tinyint(1)
Also you can use Data Type Mapping for fields of the system type Bit. Before connecting, you can set the following rule Data Type Mapping:
Code: Select all
MyConnection.DataTypeMap.AddDBTypeRule(myBit, ftBoolean);
Also, you can map data of the system type Bit using the 'Field Name' of the needed columns:
Code: Select all
MyQuery.DataTypeMap.AddFieldNameRule(YourFieldName, ftBoolean);
Re: dbCheckbox not updating - delphi
Thanks Viktor
tinyInt(1) worked and Delphi sees this as a Boolean field. Not sure why Delphi doesn't recognize an actual Boolean field.
Cheers Wallace.
tinyInt(1) worked and Delphi sees this as a Boolean field. Not sure why Delphi doesn't recognize an actual Boolean field.
Cheers Wallace.
Re: dbCheckbox not updating - delphi
It is good to see that the problem has been solved.
Feel free to contact us if you have any further questions about our products.
Feel free to contact us if you have any further questions about our products.