hi.. i'm having problem w/ my UPDATE SYNTAX .. I CAN'T FIGURE OUT WHAT'S WRONG WITH MY SYNTAX.. PLEASE HELP ME.. I REALLY NEED TO FINISH THIS FOR MY DTR SYSTEM THESIS.. i can't move on to my other codes.. please...

--the error that i get is.. UPDATE SYNTAX ERROR..

Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click


        i = MessageBox.Show("Are you sure you want to Update the record?", "Confirm Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If i = MsgBoxResult.Yes Then
            constr = "UPDATE tblEmployee SET LastName='" & txtLName.Text _
                    & "',FirstName='" & txtFName.Text _
                    & "',MI='" & txtMI.Text _
                    & "',Gender='" & cbGender.Text _
                    & "',Status='" & cbStatus.Text _
                    & "',BirthDate='" & DateTimePicker1.Text _
                    & "',Age='" & lblAge.Text _
                    & "',Religion='" & txtReligion.Text _
                    & "',BirthPlace='" & txtBirthplace.Text _
                    & "',Department='" & cbDepartment.Text _
                    & "',Address='" & txtAddress.Text _
                    & "',MobileNo='" & mskMobNo.Text _
                    & "',Access='" & txtAccess.Text _
                    & "',IDNumber='" & mskIDNo.Text _
                    & ",Password='" & txtPassword.Text _
                    & "',Position='" & cbPosition.Text _
                    & "',Shift='" & cbShift.Text _
                    & "',SSSNumber='" & txtSSS.Text _
                    & "',TIN='" & txtTIN.Text _
                    & "',PhilHealth='" & txtPhilHealth.Text _
                    & "',PAG-IBIG='" & txtPAGIBIG.Text _
                    & "' WHERE EmployeeNo=" & txtEmpNo.Text

            cmd = New OleDbCommand(constr, cn)
            cn.Open()
            i = cmd.ExecuteNonQuery()
            MessageBox.Show(i & " Record Updated Successfully!", "Techno-Time Software", MessageBoxButtons.OK, MessageBoxIcon.Information)
            cn.Close()
        End If

        Remove_Binding()
        Create_Table()
        Add_Binding()

    End Sub

thanks for ur response
uh.. what's wrong it?.. can u please explain?.. i'm sorry if i can't understand quickly

it works??
syntax error = syntax error refers to an error in the syntax of a sequence of characters or tokens that is intended to be written in a particular programming language. - wiki

your syntax is wrong that's what i see on your code for your condition... welcome and tnx also...

no, i just thanked u for having tym to reply to my thread and for you helping me fix this error.. :)

it will not work, i'll just get an error of "End of Statement expected"..

but as i checked the sequence of my columns in my database and my form they are in the same sequence..

just check your code... where the error occurs?? can you please put a breakpoint... thanz

uhm , if thats the case can u pls. help me correct my condition?..

cause i can't get into my update code anymore.. i've checked for the correct syntax of the sql update but still can't figure out my update problem..

what i wanted 2 do is to edit the info of the selected employee.. then as i clicked save.. it show a confirmation message and as i selected YES then it will save the current informations..

try this one... inform me if it works... thank u :)

Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
      i = MessageBox.Show("Are you sure you want to Update the record?", "Confirm Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
         
         If i = MsgBoxResult.Yes Then
         constr = "UPDATE tblEmployee SET LastName='" & txtLName.Text _
      & "',FirstName='" & txtFName.Text _
      & "',MI='" & txtMI.Text _
      & "',Gender='" & cbGender.Text _
      & "',Status='" & cbStatus.Text _
        & "',BirthDate='" & DateTimePicker1.Text _
        & "',Age='" & lblAge.Text _
        & "',Religion='" & txtReligion.Text _
        & "',BirthPlace='" & txtBirthplace.Text _
      & "',Department='" & cbDepartment.Text _
      & "',Address='" & txtAddress.Text _
      & "',MobileNo='" & mskMobNo.Text _
      & "',Access='" & txtAccess.Text _
        & "',IDNumber='" & mskIDNo.Text _
      & ",Password='" & txtPassword.Text _
      & "',Position='" & cbPosition.Text _
      & "',Shift='" & cbShift.Text _
      & "',SSSNumber='" & txtSSS.Text _
      & "',TIN='" & txtTIN.Text _
      & "',PhilHealth='" & txtPhilHealth.Text _
      & "',PAG-IBIG='" & txtPAGIBIG.Text _
      & "' WHERE EmployeeNo= '" & txtEmpNo.Text & "'"
      cmd = New OleDbCommand(constr, cn)
      cn.Open()

Dim Commnd as String
 Commnd = cmd.ExecuteNonQuery()
      MessageBox.Show(i & " Record Updated Successfully!", "Techno-Time Software", MessageBoxButtons.OK, MessageBoxIcon.Information)
      cn.Close()
      End If
    
      Remove_Binding()
        Create_Table()
      Add_Binding()
      End Sub

Edited 5 Years Ago by bLuEmEzzy: n/a

uhm it still has errors.. this is the error..

Syntax error (missing operator) in query expression ''1234567,Password='shunv1',Position='Teacher I',Shift='',SSSNumber='Morning',TIN='2222222',PhilHealth='222222',PAG-IBIG='222222' WHERE EmployeeNo= '2''.

Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
      i = MessageBox.Show("Are you sure you want to Update the record?", "Confirm Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
          
      If i = MsgBoxResult.Yes Then
         constr = "UPDATE tblEmployee SET LastName='" & txtLName.Text _
      & "',FirstName='" & txtFName.Text _
         & "',MI='" & txtMI.Text _
         & "',Gender='" & cbGender.Text _
         & "',Status='" & cbStatus.Text _
        & "',BirthDate='" & DateTimePicker1.Text _
        & "',Age='" & lblAge.Text _
        & "',Religion='" & txtReligion.Text _
      & "',BirthPlace='" & txtBirthplace.Text _
        & "',Department='" & cbDepartment.Text _
      & "',Address='" & txtAddress.Text _
      & "',MobileNo='" & mskMobNo.Text _
      & "',Access='" & txtAccess.Text _
      & "',IDNumber='" & mskIDNo.Text _
        & "',Password='" & txtPassword.Text _
      & "',Position='" & cbPosition.Text _
      & "',Shift='" & cbShift.Text _
      & "',SSSNumber='" & txtSSS.Text _
        & "',TIN='" & txtTIN.Text _
      & "',PhilHealth='" & txtPhilHealth.Text _
      & "',PAG-IBIG='" & txtPAGIBIG.Text _
        & "' WHERE EmployeeNo= '" & txtEmpNo.Text & "'"
      cmd = New OleDbCommand(constr, cn)
      cn.Open()

      Dim Commnd as String
        Commnd = cmd.ExecuteNonQuery()
        MessageBox.Show(i & " Record Updated Successfully!", "Techno-Time Software", MessageBoxButtons.OK, MessageBoxIcon.Information)
        cn.Close()
        End If
      Remove_Binding()
  
      Create_Table()
      Add_Binding()
      End Sub

ahm.. ive already fixed the error of missing operator but im still stuck with tha update statement error.. -_-

aw.. i can't get rid of this errors.. im just getting back and forth
-_-

Syntax error (missing operator) in query expression ''1234567' ',Password='shunv1' ''.

edit your code again ''1234567' it should be IDNumber= '" & mskIDNo.Text & "'

just review your single and double quote... thanx

ok, sorry for the very late reply i'll just check it again.. and thankx for helping me.. :)

This article has been dead for over six months. Start a new discussion instead.