0

I have a SYNTAX error in the UPDATE statement. Plz Help.

cmd.CommandText = "UPDATE tbl_User SET ([Score], [Level])VALUES(@User_Score, @User_Level) WHERE User=@User"
cmd.Parameters.AddWithValue("@User_Score", lblScore.Text)
cmd.Parameters.AddWithValue("@User_Level", lblLevel.Text)
cmd.Parameters.AddWithValue("@User", txtUser.Text)

Thanks

3
  • 1
    Does it compile? Have you checked the value of CommandText at runtime (and ran it in SQL Management?). This will narrow down your problem. Commented Jul 22, 2014 at 8:01
  • Yes i have fixed the problem. Thanks for suggestion for SQL Management Commented Jul 22, 2014 at 8:09
  • 1
    No problem, you'll get better with experience :-) Commented Jul 22, 2014 at 8:31

2 Answers 2

1

You're using the INSERT syntax style, not the UPDATE syntax:

UPDATE tbl_User SET [Score] = @User_Score, [Level]= @User_Level WHERE User=@User
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it worked. I also just figured out how to do it another correct way.
0

cmd.CommandText = "UPDATE tbl_User " & vbCrLf & "SET User_Score=@User_Score," & vbCrLf & "User_Level=@User_Level" & vbCrLf & "WHERE User=@User"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.