单击“保存”按钮时,MySQL语法出错

时间:2014-11-14 09:45:53

标签: mysql vb.net save

我在将数据保存到数据库时遇到问题。我使用带有数据库名称的MySQL数据库作为时间管理。当我单击“保存”时,我在第1行收到错误,提示我检查在我的表(datetimepicker1,payroll_no,name,time_in,time_out,time_out,losttime,reason)附近使用的MySQL语法是否正确。 这是我的代码

Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
    mysqlconn = New MySqlConnection
    mysqlconn.ConnectionString = "server=127.0.0.1;userid=root;" +
"password=;database=time management;"

    Dim command As New MySqlCommand

    If DateTimePicker1.Text = "" Or txtpayroll_no.Text = "" Or txtname.Text = "" Or txttime_in.Text = "" Or txttime_out.Text = "" Or txttime.Text = "" Then
        MsgBox("Provide All Details")
    Else
        Try
            mysqlconn.Open()
            command.Connection = mysqlconn
            command.CommandText = "INSERT into table(datetimepicker1,payroll_no,name,time_in,time_out,time_out,losttime,reason) VALUE ('" & DateTimePicker1.Text & "','" & txtpayroll_no.Text & "','" & txtname.Text & "','" & txttime_in.Text & "','" & txttime_out.Text & "','" & txttime.Text & "','" & cboreason.Text & "',)"

            command.ExecuteNonQuery()
            MsgBox("SAVED!!")
            DateTimePicker1.Text = ""
            txtpayroll_no.Text = ""
            txtname.Text = ""
            txttime_in.Text = ""
            txttime_out.Text = ""
            txttime.Text = ""
            txttime.Text = ""
            cboreason.Text = ""
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
    End If
End Sub

0 个答案:

没有答案