Solved

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

Posted on 2012-03-26
12
371 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 33

Assisted Solution

by:paulmacd
paulmacd 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
 
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 33

Expert Comment

by:paulmacd
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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 33

Expert Comment

by:paulmacd
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now