Solved

Get value of checked box in vb.net

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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