2012-05-25 82 views
2

這是我收到的錯誤:實體框架,MySQL和調用SaveChanges - 在SQL語法錯誤

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

錯誤消息告訴您確切的原因:語法錯誤。請發佈您執行的SQL。 – usr

+0

我將代碼添加到主頁 –

回答

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> 
+0

沒有爲我做的伎倆。 – Vreenak