我有这行代码:
For i As Integer = 0 To CBL.Items.Count
If CBL.Items(i).Selected Then
If i = 0 Then
myr.Close()
mycom.CommandText = "Update tbl_employee set Picture = 'Ok' where LastName='" & txtLastName.Text & "',FirstName='" & txtFirstName.Text & "' ,MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
If i = 1 Then
myr.Close()
mycom.CommandText = "Update tbl_employee set BCertificate = 'Ok' where LastName='" & txtLastName.Text & "',FirstName='" & txtFirstName.Text & "' ,MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
If i = 2 Then
myr.Close()
mycom.CommandText = "Update tbl_employee set DTest = 'Ok' where LastName='" & txtLastName.Text & "',FirstName='" & txtFirstName.Text & "' ,MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
If i = 3 Then
myr.Close()
mycom.CommandText = "Update tbl_employee set XRay = 'Ok' where LastName='" & txtLastName.Text & "',FirstName='" & txtFirstName.Text & "' ,MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
If i = 4 Then
myr.Close()
mycom.CommandText = "Update tbl_employee set MCertificate = 'Ok' where LastName='" & txtLastName.Text & "',FirstName='" & txtFirstName.Text & "' ,MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
If i = 5 Then
myr.Close()
mycom.CommandText = "Update tbl_employee set BClearance = 'Ok' where LastName='" & txtLastName.Text & "',FirstName='" & txtFirstName.Text & "' ,MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
If i = 6 Then
myr.Close()
mycom.CommandText = "Update tbl_employee set PNClearance = 'Ok' where LastName='" & txtLastName.Text & "',FirstName='" & txtFirstName.Text & "' ,MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
If i = 7 Then
myr.Close()
mycom.CommandText = "Update tbl_employee set DLicense = 'Ok' where LastName='" & txtLastName.Text & "',FirstName='" & txtFirstName.Text & "' ,MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
End If
Next
我遇到错误:未找到类型“String”上的公共(public)成员“Selected”..
我在表单加载上有以下代码:
CBL.Items.Add("Picture")
CBL.Items.Add("Birth Certificate")
CBL.Items.Add("Drug Test")
CBL.Items.Add("X-Ray")
CBL.Items.Add("Medical Certificate")
CBL.Items.Add("Barangay Clearance")
CBL.Items.Add("Police/NBI Clearance")
CBL.Items.Add("Drivers License for Drivers")
我只是这样:“我为所有项目创建了一个循环,如果选中该复选框,则该项目的索引再次传递到 if 条件,其中该项目的索引等于 sql 语句。 请任何帮助..
最佳答案
我假设 CBL 是一个 CheckedListBox。如果是这样,CBL.Items(i) 就没有 Selected
属性。您可以改用 CheckState
属性。
关于mysql - 使用 vb.net 窗口窗体中的复选框列表更新数据库中列的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27265603/