Solved

Get value of checked box in vb.net

Posted on 2006-07-20
2
168 Views
Last Modified: 2010-04-23
I want to populate a bit field in my sql database with the value 0 or 1 if a checkbox has been checked.   I was using cb1.text but that is not working.

Any help would be great!   Thanks


 Dim cmd7 As New SqlClient.SqlCommand("INSERT INTO tblEvalsurvey (Q1,q21, q22, q23, q24, q25,q26, q27, q28, q29, q210, q211, q212, q213, q214, q215,q2other, q3, q3other, q41, q42, q43, q44, q45, q46, q47, q5, q6,q7,q8,q9) VALUES ('" & rbl1.SelectedValue & "', '" & cb1.Text & "', '" & cb2.Text & "', '" & cb3.Text & "', '" & cb4.Text & "', '" & cb5.Text & "', '" & cb6.Text & "', '" & cb7.Text & "', '" & cb8.Text & "', '" & cb9.Text & "', '" & cb10.Text & "', '" & cb11.Text & "' , '" & cb12.Text & "', '" & cb13.Text & "', '" & cb14.Text & "', '" & cb15.Text & "', '" & text2.Text & "', '" & rbl3.SelectedValue & "', '" & txt3.Text & "', '" & rb41.SelectedValue & "', '" & rb42.SelectedValue & "', '" & rb43.SelectedValue & "', '" & rb44.SelectedValue & "', '" & rb45.SelectedValue & "', '" & rb46.SelectedValue & "', '" & rb47.SelectedValue & "', '" & rbl5.SelectedValue & "', '" & rbl6.SelectedValue & "', '" & txt7.Text & "', '" & txt8.Text & "', '" & txt9.Text & "')", Connection1)
0
Comment
Question by:running32
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 17146850
Try using an IIf:

..., '" & IIf(cb7.Checked,1,0) & "',...
0
 

Author Comment

by:running32
ID: 17147078
Great, thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 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