Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2012-03-26
12
Medium Priority
?
397 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 1000 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 1000 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

885 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