Syntax Error in Update Statement
VB Code:
Private Sub btnDeleteKeepInHistory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteKeepInHistory.Click
Dim objTrans As OleDb.OleDbTransaction
objCmd.CommandText = "INSERT INTO ExEmployee " & _
"([I/C Number], Name, Department, [P/C Number], [Date Joined], [Date Left], Reason) VALUES " & _
"('" & txtICNumber.Text & "', '" & txtName.Text & "', '" & txtDepartmentCode.Text & "', '" & txtPunchCardNumber.Text & "', #" & txtDateJoined.Text & "#, #" & txtDateLeft.Text & "#, '" & txtReason.Text & "')"
OleDbConnection1.Open()
objTrans = OleDbConnection1.BeginTransaction
objCmd.Transaction = objTrans
Try
objCmd.ExecuteNonQuery()
Response.Write("SQL1 Passed")
objCmd.CommandText = _
"UPDATE Employee SET Name=" & _
"'" & txtEmpty.Text & "' , " & _
"[IC Number] = '" & txtEmpty.Text & "' , " & _
"[Date Joined] = '" & txtEmpty.Text & "' , " & _
"[Confirm Letter] = '" & txtEmpty.Text & "' , " & _
"[Appointment Letter] = '" & txtEmpty.Text & "' , " & _
"Status = '" & txtEmpty.Text & "' , " & _
"Shift = '" & txtEmpty.Text & "' , " & _
"WHERE [P/C Number]='" & txtPunchCardNumber.Text & "' , "
objCmd.ExecuteNonQuery()
Response.Write("SQL2 Passed")
objTrans.Commit()
Catch ex As OleDb.OleDbException
objTrans.Rollback()
lblErrorMessage.Text = "Transaction Error...!"
TextBox1.Text = ex.Message
Return
Finally
OleDbConnection1.Close()
End Try
dgListEmployee.DataBind()
End Sub
Anyone can tell me what's wrong with my UPDATE statement, because MSG shows Syntax error in UPDATE statement.
:wave: