Solved

Get value of checked box in vb.net

Posted on 2006-07-20
2
161 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
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

22 Experts available now in Live!

Get 1:1 Help Now