"Unable to locate the update row" is reported when MYSQL is updated using ADO. Some values may have been changed after the last read. "troubleshooting _ MySQL-mysql tutorial

Source: Internet
Author: User
Tags mysql tutorial
This strange error occurred when I used ADO to connect MYSQL to update data through ODBC in DELPHI today: the row cannot be updated or located. Some 20540; may have been changed after the last read. I was puzzled, so I went online to check. Some say that there is no primary key, but this table does. today, when I use ADO in DELPHI to connect to MYSQL to update data through ODBC, this strange error occurs: unable to locate the row for update. Some values may have changed since the last read.


I was puzzled, so I went online to check. Some say that there is no primary key, but I have some in this table; some say that there are default values. I checked that all fields do not have default values; some say that they are caused by first INSERT and then EDIT, this is pure EDIT, POST, no INSERT, so it does not exist.

After searching for another half a day, I finally found a similar situation. some people say that if the data modified by EDIT is the same as the original data, this error will be reported during POST. I checked it. actually, the value assigned to the field by the EDIT operation is the same as that before the modification. if the field value is changed slightly, the POST operation can be submitted normally. The solution is to determine whether the values are the same before assigning values to the fields. this is enough for BT.

The problem is solved, but why? By enabling ODBC tracking logs for analysis, we can probably guess the cause. The following section shows the SQL trace log that assigns the same value to all fields:

BEXE 13f4-1118EXIT SQLExecDirectW with return code 0 (SQL _SUCCESS)
HSTMT 0x0362C568
WCHAR * 0x0B774FC8 [-3] "UPDATE 'test'. 'table1' SET 'table1id' = ?, 'Tid' = ?, 'Name' = ?,... 'Bkwfid' =? WHERE 'table1id' =? AND 'tid' =? AND... AND 'bkwfid' =? \ 0"
SDWORD-3

BEXE 13f4-1118 EXIT SQLRowCount with return code 0 (SQL _SUCCESS)
HSTMT 0x0362C568
SQLLEN * 0x0018E804 (0)
Note that SQLRowCount returns 0, indicating that 0 rows are updated.

The following is the SQL trace log with a value change:
BEXE 13f4-1118 EXIT SQLExecDirectW with return code 0 (SQL _SUCCESS)
HSTMT 0x0362C568
WCHAR * 0x0B76FEC8 [-3] "UPDATE 'test'. 'table1' SET 'table1id' = ?, 'Tid' = ?, 'Name' = ?,... 'Bkwfid' =? WHERE 'table1id' =? AND 'tid' =? AND... AND 'bkwfid' =? \ 0"
SDWORD-3

BEXE 13f4-1118 EXIT SQLRowCount with return code 0 (SQL _SUCCESS)
HSTMT 0x0362C568
SQLLEN * 0x0018E804 (1)

At this time, SQLRowCount returns 1, which indicates that one row is updated.

The two SQL statements are identical, except that the content of the record after the previous SQL statement is executed is not changed, and the other one is changed! Then MYSQL will tell you that you have not updated any records. In fact, you have updated a record, but the results are the same before and after UPDATE, which has the same effect as those without UPDATE, so MYSQL returned 0, so ADO thought that the data was not updated, so it was deemed that someone else had modified the data, so it reported the error "unable to UPDATE the location Line.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.