0

I'm a beginner in mysql c# programming. I ran into the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"pass where username=admin1' at line 1

my "update_user_password" function is the following:

public Boolean update_user_password(string user_name, string new_password)
    {
        String uu = "update users set password=\"" + new_password + " where username=" + user_name;
        Boolean error = !execute_cmd_db(uu.ToString());
        return !error;
    }

Can anyone please tell me how I can fix this error?

1
  • 3
    you could fix it by adding some quotes, but I'm encouraging you to use prepared statements. Commented Jul 30, 2014 at 7:30

1 Answer 1

1

You have to use quotes around the values of username and password:

String uu = "update users set password'\" + new_password + "' where username='" + user_name+"'";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.