0

Hi guys - whenever i run this code i get " SYNTAX ERROR (MISSING OPERATOR) IN QUERY EXPRESSION" - ive checked everywhere and cant find a solution

can anybody spot any errors here?

Try
            Dim updatecon As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;data source=H:\FROM HOME\EXTENDED PROJECT !!!!!!\Databases\Login Details.accdb")
            updatecon.Open()
            Dim updatecmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("Update CustomerDetails SET Surname = '" & txtSurname.Text & "' AND Gender = '" & txtGender.Text & "' and FirstName = '" & txtForeName.Text & "' and Address1 = '" & txtAddress1.Text & "' and address2 = '" & txtAddress2.Text & "' and CarMake = '" & txtCarmake.Text & "' and CarModel = '" & txtModel.Text & "' and PostCode = '" & txtPostCode.Text & "' and HouseNumber = " & txtHouseNo.Text & " and ContactNumber1 = " & txtContactNo.Text & " and ContactNumber2 = " & txtContactNo2.Text & " and BorrowingAmmount = " & txtBorrowing.Text & " and YearlyIncome = " & txtYearly.Text & " and CreditRating = " & txtCredit.Text & " and Deposit = " & txtDeposit.Text & " and DOB = " & DateBirth.Text & " and Price = " & txtPrice.Text & " and Employed = " & chkEmployed.CheckState & " where Reference=" & txtReference.Text & " ", updatecon)

            updatecmd.ExecuteNonQuery()
            MsgBox("Record has been updated")
        Catch ex As OleDb.OleDbException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Oledb Error")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")

        End Try
2
Contributors
1
Reply
6
Views
6 Years
Discussion Span
Last Post by __avd
0

Take a look at Update statement syntax.

Always use Parameters.

Dim updatecmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("Update CustomerDetails SET Surname =@surname,Gender =@gender,FirstName = @firstname,Address1 = @address1, address2 = @address2 where Reference=@reference", updatecon)

updatecmd.Parameters.AddWithValue("@surname",txtSurname.Text)
....
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.