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 SubCode: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 SubCode: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 SubCode:Public Sub AddParam(Name As String, Value As Object) Dim NewParam As New OleDbParameter(Name, Value) Params.Add(NewParam) End Sub




Reply With Quote
