C# DBConcurrencyException MySqlCommandBuilder

C# DBConcurrencyException MySqlCommandBuilder,c#,mysql,C#,Mysql,在修改DataGridView中的数据时,出现异常: DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records 当我这样做时: // myTable is the DataSource of the datagridview. myAdapter.Update(myTable); VS2010调试器在尝试更新时告诉我这是updateCommand:

在修改
DataGridView
中的数据时,出现异常:

DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records
当我这样做时:

// myTable is the DataSource of the datagridview.
myAdapter.Update(myTable);
VS2010调试器在尝试更新时告诉我这是
updateCommand

UPDATE `MySchema`.`MyDatabase` 
SET `EmployeeFirstName` = @p1 
WHERE ((`ID` = @p2) AND (`EmployeePhoneNumber` = @p3) AND
       (`EmployeeFirstName` = @p4))

@p1 is Joe (new value changed in the datagridview)
@p4 is Sally (database value)
问题:


如果数据库中存在
WHERE
子句,为什么会得到
DBConcurrencyException
?(没有实际的更改,因此没有任何并发冲突)

此异常是因为“这是您的DataAdapter实例在说话:可能其他人已经完成了您尝试的更新,这就是为什么我要更新0行,而我预期要更新X行。”。正确,但Sally仍然留在数据库中。我希望是乔。我不明白适配器为什么撒谎。不,不是。如果Sally仍然是Sally,实际上没有任何记录被更改-这就是它所说的。您需要找出为什么没有更改任何记录。一个可能的原因就是这个例外的本质(见我之前的评论)。您确定在您发出更新呼叫时,您自己的应用或任何其他用户/应用都没有更改记录吗?很抱歉,没有更多信息,我只能提出更多建议。您的DataTable是否绑定到GidView?已解决!问题是(错误地)EmployeePhoneNumber是一个浮点,因此datagridview显示类似于1.0923E1的内容,而在数据库中,值是10923…因此数据库中不存在WHERE子句。