Inserting values OK in mysql database i check box state is checked

谁说胖子不能爱 提交于 2019-12-25 01:14:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!