[Gambas-user] Problem with boolean values in a class file
richard terry
rterry at ...1822...
Sun Feb 3 22:14:08 CET 2008
I'm having trouble saving the contents of a checkbox value into my postgres
database.
I have a class file call cAddress, which contains amongst a few others these
lines:
PUBLIC preferred_address AS Boolean
PUBLIC postal_address AS Boolean
In my main form which contains a couple of check boxes, when I collect data I
do the following:
currentAddress = New cAddress
When I collect the data I've entered I do this
currentAddress preferred_address = chkpreferredAddress.value
currentAddress postal_address = chkPostalAddress.value
currentAddress .HeadOffice = FALSE (which I want to be false here)
I then have a file I call modContactsDBI which contains all the sql calls to
my postgres database.
modContactsDBI.person_address_save(currentAddress, currentPerson.pk)
in modContactsDBI the subroutine is this:
PUBLIC SUB person_address_save(address AS cAddress, pk_person AS Integer)
In this routine I construct the sql to send to the database from the values in
passed to the routine
sql = sql & address.preferred_address & ", "
sql = sql & address.postal_address & ", "
What happens is interesting in the the sql ends up looking like this:
Insert into data_addresses (street, fk_town, postal_address,
preferred,head_office,country_code) VALUES("1 Any Street",922,T,T, , "AU")
Note the section here ************T,T, , *******************
ie what was True in the chkPostal checkbox (ie TRUE) ends up as a T, which
postgres spits the dummy at, and what was Head_Office which I set to False
(or even if another chbox.value was FALSE, there ends up nothing in its spot
in the query, as shown above (the blank space between the two comma's.
Any ideas, thanks in advance.
Richard
More information about the User
mailing list