4

Am developing application using Delphi 7 and Sql Server express 2008 R2 , am using BDE to connect Sql Server through ODBC, and SQL Native Client is used for driver.

In some particular forms the table component raise EDBEngineError 'Record has been changed by another user' , am just try to append a data, the same problem occur when table.cancel, table.post, table.edit.....

Few days before i changed driver from SQL Server to Sql Native Client because of sql server has problem with "connection has a result set for another hstmt" , so that i changed it to SQL Native client, form this i met this 'Record has been changed by antoher user' error.

Please any one help

da-soft
  • 7,670
  • 28
  • 36
bejarun
  • 175
  • 3
  • 11
  • you need to find a way to see the generated SQL to find the root cause, I recommend to compile with "Use Debug DCUs" and step into the BDE source code, until you can see the generated SQL string. I solved a similar provlem with dbExpress lately. – mjn Jan 30 '12 at 15:23

2 Answers2

5
  1. BDE is not updated long time. And SQL Native Client is updating regularly. Possibly you run into incompatibility of BDE and SQLNC v 10.5.
  2. "Record has been changed by another user" means, that API returned <> 1 of the updated records, for example 0 records. In most cases it is not really, that some user changed the record. The number of updated records is returned as a separate message, so if a connection is busy with other messages, then it may return 0. If your tables have the triggers, then try to add SET NOCOUNT ON at top of a trigger.
  3. "Connection is busy with result set for another hstmt" means, that you have not fetched all records from an active result set. You can try fetching all records.
  4. To avoid all these errors, consider to migrate to a dbExpress or a 3d party library like AnyDAC.

Addition to (2): Other classical reason for "Record has been changed by another user". The WHERE phrase includes a field and a corresponding parameter, which do not match by precision (eg, precision is losted at client side), have different formats (eg, incompatible character sets), etc. You have to check the SQL command and parameter values sent to SQL Server using SQL Profiler.

da-soft
  • 7,670
  • 28
  • 36
  • dbExpress still has its problems which may cause the same error - for example lack of support for milliseconds (with InterBase) – mjn Jan 30 '12 at 15:23
  • thank you for your reply,, befor that i want to say one thing,, – bejarun Jan 31 '12 at 06:45
  • thank you for your reply,, first am developed this application using "Paradox' db, after that am migrate into sql server ,, i have 100 tables components in datamodule, so it is not easy to change all it to another 3rd part comp, create OBDC datasources and connect it via BDE,, and this 'record locked by another user error will occur only in temperary tables (table name start with '#'),, am also tried with sqlserver driver, am not able find which query is partially fetched data, so i convert into sqlnative client, after i changed that 'hstmt error gone' but record locked error came,, – bejarun Jan 31 '12 at 06:52
  • Nice list by @da-soft.. We had same problem.. And in our case, we found that one of the triggers on a particular table was executing 'PRINT' statement. We commented it out and that resolved the error. – NamoRamana Oct 13 '20 at 18:37
0

My friend, you should consider update your developing tools. For this problem you should really work with the ZEOS Component Pack for Delphi. It can connect to many kinds of databases, including Firebird, MySQL, Access and SQL Server. All you have to do is put the dll of the database you are using in your project directory and bin direcoty of delphi (if the target computer does not have the database manager). Then you let the database server to take care of the transactions. If you need more details, just give me a signal.

NaN
  • 8,596
  • 20
  • 79
  • 153