Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Jul 18, 2019 6:20 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Radio and select button values in databases...
PostPosted: Tue Mar 15, 2011 11:50 am 
Offline
User avatar

Joined: Wed Jul 07, 2010 2:55 pm
Posts: 720
Location: University Of Calgary, Faculty Of Medicine
I have a gui with a few radio buttons and a check box.

I'm curious what methods I should use to take these controls values and store them in a database and vise versa.

The radio button is an integer in the database.
The check box is a BOOL in the database.

_________________
If at first you don't succeed... Try REALBasic and if that doesn't work try Xojo.


Top
 Profile  
Reply with quote  
 Post subject: Re: Radio and select button values in databases...
PostPosted: Tue Mar 15, 2011 12:46 pm 
Offline
User avatar

Joined: Wed Nov 15, 2006 3:50 pm
Posts: 2353
Location: England
Quote:
The radio button is an integer in the database.
The check box is a BOOL in the database.


That looks like you already answered your own question.

Set the radio buttons set up as an array. (all the radiobuttons have the same name, but they have different index values)
When the selected one is changed, the index property is the integer you want.
Put that into an integer variable. (eg intSelectedRadioItem)

To store, just store the value of that integer.
integerdatabasefield = intSelectedRadioItem

To store the boolean value,
booleandatabasefield = chkSomething.value



When retrieving,
chkSomething.value = booleandatabasefield
btnRadio(integerdatabasefield).value = true


Top
 Profile  
Reply with quote  
 Post subject: Re: Radio and select button values in databases...
PostPosted: Tue Mar 15, 2011 2:45 pm 
Offline
User avatar

Joined: Wed Jul 07, 2010 2:55 pm
Posts: 720
Location: University Of Calgary, Faculty Of Medicine
So...

dim s as string
s = "SELECT * from Table where CheckBox = " + str(CheckBox).Value + ";" 'CheckBox` TINYINT(1)
s = "SELECT * from Table where RadioButton = " + str(RadioButton) + ";" 'RadioButton` TINYINT(1)
The checkbox seems straight forward, but I think I need to have a property that is set in the Radiobuttons action.
Correct?

Maybe I should make the RadioButton and CheckBox Controls computed properties?

_________________
If at first you don't succeed... Try REALBasic and if that doesn't work try Xojo.


Top
 Profile  
Reply with quote  
 Post subject: Re: Radio and select button values in databases...
PostPosted: Tue Mar 15, 2011 3:08 pm 
Offline
User avatar

Joined: Wed Nov 15, 2006 3:50 pm
Posts: 2353
Location: England
]Hmm.
OK, so you are building up a SQL string, not dealing with fields from a recordset.

You said
Quote:
The radio button is an integer in the database.
The check box is a BOOL in the database.


But your sample code suggests otherwise

TINYINT(1) is not really boolean.. it will be 0 or 1 rather than true or false.
However some SQL implementations treat them the same

'checkbox
if checkbox.value then
s = "SELECT * from Table where CheckBox = 1"
else
s = "SELECT * from Table where CheckBox = 0"
end if


'radiobutton

dim x as integer
for x = 0 to 4 'how many radiobuttons?
if radiobutton(x).value then
s = "SELECT * from Table where RadioButton = " + str(x)
end if
next


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group