使用checkedlistBox的多个Checkbox选择代码 [英] Multiple Checkbox selecteion code using checkedlistBox
本文介绍了使用checkedlistBox的多个Checkbox选择代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是如何使用vb.net2008中的checkedListbox将多个选定值插入到Sql Server2005 ...我在其中使用CheckedlistBox1和一个comboBox ...
我的代码是这样的:
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理Button1.Click
My question is how to Insert Multiple Selected values using checkedListbox in vb.net2008 to Sql Server2005... In which i am using CheckedlistBox1 and One comboBox ...
My code is this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each item As CheckedListBox In CheckedListBox1.Items
If item.SelectedItems.ToString Then
'Insert code for inserting data to SQL
cmd.CommandText = "insert into Module_Control_tbl (empl_ID,Module_ID) Values('" & ComboBox1.SelectedValue & "','" & CheckedListBox1.SelectedValue & "')"
ComboBox1.Focus()
cmd.Connection = Cn
cmd.ExecuteNonQuery()
MsgBox("Assign Module Successfully to Employee")
Form7_Load(sender, e)
End If
Next
推荐答案
参考: using-checkedlistbox-in-vb-net2008 [ ^ ]
这篇关于使用checkedlistBox的多个Checkbox选择代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文