Results 1 to 16 of 16

Thread: [RESOLVED] Syntax error in UPDATE statement

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    705

    Resolved [RESOLVED] Syntax error in UPDATE statement

    I seem to be unable to execute this query and am unable to see the error of my ways. When run, I keep getting this error message, "Syntax error in UPDATE statement."

    I run the following routine to save data that has been input to a form. I am completely unable to see the syntax error in my query. I therefore believe that the error is actually something else, but I have no idea what that could be.

    Code:
        Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
            AddParams()
            UpdateRecord()
            SetState("View")
        End Sub

    Code:
        Private Sub AddParams()
            MasterBase.AddParam("@recno", lblEmployeeID.Text)
            MasterBase.AddParam("@first", txtFirstName.Text)
            MasterBase.AddParam("@middle", txtMiddleName.Text)
            MasterBase.AddParam("@last", txtLastName.Text)
            MasterBase.AddParam("@dept", cboDepartment.Text)
            MasterBase.AddParam("@title", txtJobTitle.Text)
            MasterBase.AddParam("@description", txtJobDescription.Text)
            MasterBase.AddParam("@hire", txtEmployed.Text)
            MasterBase.AddParam("@terminate", txtDischarged.Text)
            MasterBase.AddParam("@user", txtUser.Text)
            MasterBase.AddParam("@pass", txtPassword.Text)
            MasterBase.AddParam("@active", chkActive.Checked)
        End Sub
    Code:
        Private Sub UpdateRecord()
            MasterBase.MasterBaseQuery("UPDATE empEmployeeInformation " &
                                       "SET EmployeeID=@recno,FirstName=@first,MiddleName=@middle,LastName=@last," &
                                       "Department=@dept,JobTitle=@title,JobDescription=@description," &
                                       "Hire=@hire,Terminate=@terminate,UserName=@user,Password=@pass,Active=@active " &
                                       "WHERE EmployeeID=@recno")
            If NoErrors(True) = False Then Exit Sub
    Code:
            Public Sub MasterBaseQuery(MyQuery As String)
                RecordCount = 0
                Exception = ""
                Try
                    MasterBaseConnection.Open() 'Open connection
                    ListCommand = New OleDbCommand(MyQuery, MasterBaseConnection) 'Database Command
                    Params.ForEach(Sub(p) ListCommand.Parameters.Add(p)) 'Load params into command
                    Params.Clear() 'Clear params list
                    ListTable = New DataTable
                    ListAdapter = New OleDbDataAdapter(ListCommand)
                    RecordCount = ListAdapter.Fill(ListTable)
                Catch ex As Exception
                    Exception = ex.Message
                End Try
                If MasterBaseConnection.State = ConnectionState.Open Then MasterBaseConnection.Close()
            End Sub
            End Sub
    Code:
            Public Sub AddParam(Name As String, Value As Object)
                Dim NewParam As New OleDbParameter(Name, Value)
                Params.Add(NewParam)
            End Sub
    Last edited by gwboolean; Oct 13th, 2021 at 03:25 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width