Solved

Get value of checked box in vb.net

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Gridview selected row 9 50
VB.NET Repostiory Pattern 7 52
VB.NET 2008 - SQL Timeout 9 34
Open a link in vb.net 2 16
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 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