问题
You may try to state that this is duplicate, but as far as i haved search the stack overflow and some search engines, i have realized that none of them answers my problem, so here is my code:
This is for my save button
If chkPic.CheckState = CheckState.Checked Then
myr.Close()
mycom.CommandText = "Insert into tbl_employee(Picture) values (Ok) where LastName = '" & txtLastName.Text & "' AND FirstName = '" & txtFirstName.Text & "' AND MiddleName = '" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
End If
This is for my update button
If chkPic.Checked Then
myr.Close()
mycom.CommandText = "Update tbl_employee set Picture = '& Ok &' where LastName='" & txtLastName.Text & "' and FirstName='" & txtFirstName.Text & "' and MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
Else
myr.Close()
mycom.CommandText = "Update tbl_employee set Picture = '' where LastName='" & txtLastName.Text & "' and FirstName='" & txtFirstName.Text & "' and MiddleName='" & txtMiddleName.Text & "' "
myr = mycom.ExecuteReader
myr.Close()
End If
And i would also like to consider how to read its data in my lost focus event, which i coded as:
If myr(75) = "Ok" Then
chkPic.CheckState = CheckState.Checked
Else
chkPic.CheckState = CheckState.Unchecked
End If
Any help please anyone.. Thanks
来源:https://stackoverflow.com/questions/27222855/inserting-values-ok-in-mysql-database-i-check-box-state-is-checked