Will that work for .NET?
Main Topics
Browse All TopicsHello experts,
Does anyone know of a way to store the value of a checkbox on an ASP page in a SQL table as either a true or false value? I know how to retrieve the info from SQL, but not insert it. Currently the method I am using sets the value to true regardless of what is checked on the form.
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
what data type does the database column have?
how are you doing it now?
you can use that while building a sql statement as well.
query = "insert into table (txt1, txt2, txt3, chk1,num1) values (" & _
"'" & request.form("text1") & "'," & _
"'" & request.form("text2") & "'," & _
"'" & request.form("text3") & "',"
if request.form("chkbox") = "givenvalue" then
query = query & "1,"
else
query = query & "0,"
end if
query = query & request.form("number1") & ")"
conn.execute query
one thing I found was that depending on the type of data connection you have-- or datasource--you might have to use a synax for passing the parameters into the update and insert statements. Usually most examples show using @variable in the update syntax but for example with the MySql ODBC driver you have to put the update string together like this: "update tablename set var1=?, var2=? where columnX=?"
Like WMIF said though, this is the oldschool ASP topic area.
It's best to forget about T/F and store it as character data.
Interpret the results and decide if f=0 and t=1 and then store the right data.
Then you can make it "stickY" by doing
<%if recordset.fields.item("imp
The corresponding code is
<input type="checkbox" <see above code> name="thischeckbox"> check here
{this is an example so it's designed to hit the highlights, not execute properly}
<%if request.form("thischeckbox
at the end of your row do a recordset.update
-make sure the recordset is updateable
this keeps your code compact and simple, it lets you execute and update at the same time.
IT's not as "clean" but it's easier to debug IMHO and simpler to find when you are chasing down a bug or an update.
>>It's best to forget about T/F and store it as character data.
how is that any different than the code i gave above? since the question was about storing the data into a db, i gave code in that context:
if request.form("chkbox") = "givenvalue" then
query = query & "1,"
else
query = query & "0,"
end if
Business Accounts
Answer for Membership
by: WMIFPosted on 2006-11-01 at 14:00:54ID: 17853559
you need to test for the value of the checkbox. then set the value to true.
if request.form("chkbox") = "givenvalue" then
insert into table (checkcol) values ('true')
else
insert into table (checkcol) values ('false')
end if