Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Webmatrix.WebData.WebSecurity与MySql不兼容。在WebSecurity.UserExists()检查中引发sql语法错误_C#_Mysql_Asp.net Mvc_Asp.net Mvc 5_Asp.net Membership - Fatal编程技术网

C# Webmatrix.WebData.WebSecurity与MySql不兼容。在WebSecurity.UserExists()检查中引发sql语法错误

C# Webmatrix.WebData.WebSecurity与MySql不兼容。在WebSecurity.UserExists()检查中引发sql语法错误,c#,mysql,asp.net-mvc,asp.net-mvc-5,asp.net-membership,C#,Mysql,Asp.net Mvc,Asp.net Mvc 5,Asp.net Membership,我用MSSQL完成了一个项目。我将MSSQL迁移到MySql,因为我认为Webmatrix.WebData也将支持MySql。Web安全初始化成功 if (!WebSecurity.Initialized) { securityService.Initialize( "sqlserver", "UserProfile", "UserId"

我用MSSQL完成了一个项目。我将MSSQL迁移到MySql,因为我认为Webmatrix.WebData也将支持MySql。Web安全初始化成功

if (!WebSecurity.Initialized)
     {
          securityService.Initialize(
          "sqlserver",
          "UserProfile",
          "UserId"
          "UserName");
      };` 
以上代码已成功执行。但如果未能执行以下部分

 if (!WebSecurity.UserExists("user"))
        {
            WebSecurity.CreateUserAndAccount("user", "password");
        }
检查
WebSecurity.UserExists(“用户”)
失败。这是错误消息-

MySql.Data.dll中发生“MySql.Data.MySqlClient.MySqlException”类型的异常,但未在用户代码中处理

附加信息:您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以获得在第1行的“[UserTable]中的[UserId]附近使用的正确语法,其中(UPPER([UserName])=UPPER('user')”


请帮我解决这个问题。

ASP.Net附带的Web安全性(上面代码中使用的)在代码中嵌入了一些Microsoft T-SQL语法。MySQL语法和MSSQL之间几乎没有区别,这可能是错误的原因

从显示的错误中,我可以看到WebSecurity中的
CreateUserAndAccount
方法试图执行T-SQL语句
。。。。[UserTable]中的[UserId],其中(UPPER([UserName])=UPPER('user'))
然而,尽管这在MSSQL中可以工作,但方括号
“[”
“]”
将在MySQL中导致错误

解决方法是使用
MySql.Web.Security.MySqlWebSecurity.CreateUserAndAccount(“用户”、“密码”)
,当然,您可以使用
语句添加
,也可以这样使用