两个SQL一模一样,区别只在于前一个SQL执行后记录内容没有变化,而后一个是有变化!然后对于没变化的情况MYSQL就告诉你,你没有UPDATE任何记录,其实你是UPDATE了一条记录,只是UPDATE前后结果一样,跟没有UPDATE的效果相同,于是MYSQL返回了0,于是ADO认为没UPDATE到数据,于是认为是别人把数据修改掉了,于是就报“无法为更新定位行”的错误了。
补充:
后来接着研究,为了验证这个问题,直接用SQL命令更新一条NAME='公告'的记录:
mysql> update table1 set name='公告' where table1id=1;
Query OK, 0 rows affected
Rows matched: 1 Changed: 0 Warnings: 0
mysql> update table1 set name='公告1' where table1id=1;
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
显然是因为相同值时返回的0 rows affected导致了问题。
然后再上网搜索时,发现MYSQL官方有这个问题的说明,只需要修改MYSQL的ODBC连接配置即可解决: http://dev.mysql.com/doc/connector-odbc/en/connector-odbc-errors.html Write Conflicts or Row Location ErrorsHow do I handle Write Conflicts or Row Location errors?
If you see the following errors, select the Return Matching Rows option in the DSN configuration dialog, or specifyOPTION=2, as the connection parameter:
Write Conflict. Another user has changed your data.Row cannot be located for updating. Some values may have been changedsince it was last read. 于是照着修改了一下ODBC的连接配置: