mjn
mjn

Reputation: 36644

dbExpress "Record not found or changed by another user"

How do I find the reason for a "Record not found or changed by another user" error when working with dbExpress?

How do I find the SQL statement (with the actual parameter values) that fails?

Upvotes: 4

Views: 3541

Answers (1)

mjn
mjn

Reputation: 36644

  • make sure that the compiler uses Debug DCUs.

  • set a breakpoint in the first line of the Procedure TSQLResolver.DoExecSQL in unit db\Provider

  • run the operation which causes the error message (for example, modifying a record in a data-aware component)

  • if the debugger stops, the generated SQL command can be viewed

  • check the SQL statement for conditions which could cause the error

At this point, only constant expressions in the statement like ... 'where Field1 is null and Field2 = 0' can be checked. in DoExecSQL, the SQL statement uses placeholders (?) for parameter values, so if the constant expression conditions did not show anything helpful, continue debugging:

  • to see the actual parameter values, set a breakpoint in function TSQLConnection.Execute (in unit SqlExpr) and step through the parameter evaluation loop.

Upvotes: 8

Related Questions