c# - mysql 函数的正确语法

标签 c# mysql asp.net

我是 mysql C# 编程的初学者。 我遇到了以下错误:

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

我的“update_user_password”函数如下:

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;
    }

谁能告诉我如何修复这个错误?

最佳答案

您必须在用户名和密码值周围使用引号:

String uu = "update users set password'\" + new_password + "' where username='" + user_name+"'";

关于c# - mysql 函数的正确语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25031012/

相关文章:

c# - 从 SQL 返回 2 个结果

c# : simulate memory leaks

php - 查询在 XAMPP 中有效,但在 AWS 云中的 LAMP 堆栈中无效

c# - 获取IPEndPoint的动态分配端口

mysql - 努力通过关系添加 has_many

mysql - Django : mysql : 1045,“用户访问被拒绝

c# - 带有是或否按钮的 JavaScript 警报

c# - 如何为单选按钮列表创建数据源?

c# - 如何在 c# 中删除没有 SqlDataSource 的 gridview 中的行?

c# - 如何获取最新的文件后缀名c#