Solved

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

Posted on 2012-03-26
12
381 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

713 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