hi...i am a new user of vb.net and i want to have a code where changes in my existing data could be save when i click the button "update"...can anyone help me about this matter?...here's my code for the said matter...

Private Sub menu_update_Click(sender As Object, e As EventArgs) Handles menu_update.Click
        access = "UPDATE tbl_location WHERE locid = @locid SET locname = @locname, locadd = @locadd"

        con.Open()
        cmd = New OleDbCommand(access, con)

        cmd.Parameters.AddWithValue("@txt_locname", txt_locname)
        cmd.Parameters.AddWithValue("@txt_locadd", txt_locadd)
        cmd.ExecuteNonQuery()
        MsgBox("Successfully Updated...")
        con.Close()

        Me.menu_update.Enabled = False
        Me.menu_save.Enabled = False

        Me.txt_locname.Enabled = False
        Me.txt_locadd.Enabled = False

    End Sub

when i run the program, error appeared that there is an error in my update statement.

Recommended Answers

All 2 Replies

If you are using OleDb then try

access = "UPDATE tbl_location WHERE locid = ? SET locname = ?, locadd = ?"

thank you for the answer.. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.