gpt4 book ai didi

mysql - Entity Framework 、MySQL、SaveChanges - SQL 语法错误

转载 作者:行者123 更新时间:2023-11-29 03:43:03 26 4
gpt4 key购买 nike

这是我遇到的错误:

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 被删除,这可能表明 MySql 驱动器中存在一些字符串缓冲区问题

我正在使用 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;
}

最佳答案

我自己解决了这个问题,问题是 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>

关于mysql - Entity Framework 、MySQL、SaveChanges - SQL 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10760824/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com