【问题标题】:Entity Framework, MySQL, SaveChanges - Error in SQL syntax实体框架、MySQL、SaveChanges - SQL 语法错误
【发布时间】:2012-05-26 05:14:28
【问题描述】:

这是我得到的错误:

Server Error in '/' Application.

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 'group) VALUES ('test_user','testpass',13,77,0,0,0,1);SE' at line 9

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MySql.Data.MySqlClient.MySqlException: 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 'group) VALUES ('test_user', 'testpass', 13, 77, 0, 0, 0, 1); SE' at line 9

我环顾四周,有人解释说这可能是 mysql 缓冲区的问题SELECT is stripped which may indicate some string buffer problems in the MySql drive

我正在使用 MySQL 连接器版本 6.5.4.0

感谢任何帮助

根据要求,这是我用来插入的代码:

public bool CreateMember(string username, string password, int age, int residence)
{
    Context.Members.AddObject(new MemberEntity { Username = username, Password = password, Age = age, Residence = residence, Banned = false, Locked = false, Online = false, Group = 1 });
    return Context.SaveChanges() > 0;
}

【问题讨论】:

  • 错误信息告诉你确切的原因:语法错误。请发布您执行的 SQL。
  • 我在主页添加了代码

标签: mysql entity-framework entity-framework-4


【解决方案1】:

我自己解决了这个问题,问题是 machine.config 上的 MySQL 连接器过时,我已经在我的 Web.config 中添加了以下代码,它已经解决了这个问题:

<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider"
           invariant="MySql.Data.MySqlClient"
           description=".Net Framework Data Provider for MySQL"
           type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />       
    </DbProviderFactories>
</system.data>

【讨论】:

    猜你喜欢
    • 2016-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-19
    • 1970-01-01
    • 2021-11-15
    • 1970-01-01
    相关资源
    最近更新 更多