面对错误的mysql查询不正确检查手册 [英] Facing error of mysql query not proper check in manual
问题描述
我试图通过c#代码向mysql服务器数据库发出此查询,但发生了以下错误。我的查询错了吗请帮助。我正在使用mysql服务器5.0
string chkUser =Select * FROM [User] where Email ='+ UserName +'AND Password ='+ Password + ';;
您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在附近使用正确的语法
我尝试过:
我试图通过c#代码向mysql服务器数据库发出此查询,但发生了以下错误。我的查询错了吗请帮助。我正在使用mysql服务器5.0
string chkUser =Select * FROM [User] where Email ='+ UserName +'AND Password ='+ Password + ';;
您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在
I am trying to fire this query through c# code to mysql server database but following error is occurred. Is my query wrong. plz help. I am using mysql server 5.0
string chkUser = "Select * FROM [User] where Email='"+ UserName + "'AND Password='" + Password + "';";
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
What I have tried:
I am trying to fire this query through c# code to mysql server database but following error is occurred. Is my query wrong. plz help. I am using mysql server 5.0
string chkUser = "Select * FROM [User] where Email='"+ UserName + "'AND Password='" + Password + "';";
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
推荐答案
附近使用正确的语法。您的查询应该是
Your query should be
string chkUser = "Select * FROM [User] where Email=@UserName AND Password=@Password;";
使用命令参数提供 @UserName
的值和 @Password
你说过你知道这件事所以我没有提供一个例子。
注意之前的空格AND
Use command parameters to provide the values for @UserName
and @Password
You've said you know about this so I haven't provided an example.
Note the space before AND
这篇关于面对错误的mysql查询不正确检查手册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!