Solved

SQL Data Type for radio question Yes/No - Please specify text type

Posted on 2012-03-26
12
379 Views
Last Modified: 2012-03-27
In SQL Which Data type I should choose to create those field in SQL

YES ?   No ?? (Same field contactMe) which Data Type ?
Please specify (ContactMeSpecify") which data type ?

And you do you recommand this data type please advice...


Would your give a course?

( ) Yes  () No
please specify: [                           ]


<input type="radio" name="contactMe" id="ContactMeYes" value="Yes">&nbsp;<label for="ContactMeYes">Yes</label>

<input type="radio" name="ContactMe" id="ContactMeNo" value="No">&nbsp;<label for="ContactMeNo">No <br>

(please specify)</label>
<input type="text" name="ContactMeSpecify" id="ContactMeSpecify" value="" maxlength="255" size="30" style="width: 200px;">
0
Comment
Question by:LelloLello
  • 6
  • 3
  • 3
12 Comments
 
LVL 9

Accepted Solution

by:
OCDan earned 250 total points
ID: 37767729
Any field that only takes a yes or no response should be set as a BIT field. This takes up the smallest amount of data and is the recommended way to go.
0
 
LVL 34

Assisted Solution

by:Paul MacDonald
Paul MacDonald earned 250 total points
ID: 37767733
Boolean for all single bit binary (yes/no, 1/0, true/false) data.
0
 

Author Comment

by:LelloLello
ID: 37767784
Okay thank you i have a choose a bit type

Should I choose allow nulls ? [  ]

I got that msg.

'volunteers' table
- Unable to modify table.  
ALTER TABLE only allows columns to be added that can contain nulls or have a DEFAULT definition specified. Column 'contactMe' cannot be added to table 'volunteers' because it does not allow nulls and does not specify a DEFAULT definition.

what that mean?
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 9

Expert Comment

by:OCDan
ID: 37767792
I normally wouldn't allow null, and I would set a default value of 0 so that you aren't getting any false positives.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 37767804
Unless you need the third state (null), I would establish a default value for the column.

Leaving the default as null would let you know the data had purposely been filled in, but then you have to check for a null value when you read from the column.
0
 

Author Comment

by:LelloLello
ID: 37767828
so should i check the 'allow nulls' checkbox.
0
 

Author Comment

by:LelloLello
ID: 37767841
so in the database i should insert Yes/No ?
0
 

Author Comment

by:LelloLello
ID: 37767844
<cfquery name="logAnnualDues" datasource="#application.datasource#" username="#application.username#" password="#application.password#">
                  INSERT INTO volunteers (user_id, id_number, firstname, lastname, datereg)
                VALUES (
                <cfqueryparam value = "#form.user_id#" CFSQLType = "CF_SQL_INTEGER" />,
                <cfqueryparam value = "#form.id_number#" cfsqltype="CF_SQL_INTEGER" />,
                <cfqueryparam value = "#form.firstname#" CFSQLType = "CF_SQL_VARCHAR" /> ,
                <cfqueryparam value = "#form.lastname#" CFSQLType = "CF_SQL_VARCHAR" /> ,
              '#DateFormat(NOW())#',
                <cfqueryparam value = "#form.contactMe#" cfsqltype="cf_sql_bit" />
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 37767847
I wouldn't, unless you need to.  Set it so it has a default value (either true or false, depending on what you're storing).  

If you need to allow nulls, then by all means check the box.
0
 

Author Comment

by:LelloLello
ID: 37767858
i want the user to choosee yes or no.
0
 

Author Comment

by:LelloLello
ID: 37767872
well what i should do if i don't check the 'allow nulls' the SQL doesn't let me save it.  

In column Properties, which data i should change if i don't want to check the box of 'allow nulls.
0
 
LVL 9

Expert Comment

by:OCDan
ID: 37767938
It should let you if you set a default value.The error message stated you must either allow nulls OR enter a default value.

 If the user has to pick one or the other having a default value will not make any difference, but it will let you save it.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question