Sql – Row cannot be found for Locate

adoadvantage-database-serverdelphisql-serversql-server-2005

I'm converting existing Advantage Database Server application to SQL Server 2005 using D2009, dbGo (ADO). Sometimes i experience the error row cannot be found for locating. I had googled it, according to results i needed to set Update Criteria property of each ADOTable and set cursor location to dynamic. I did so, but sometimes i still get same error. All of the tables has primary key so I've been using

Query.Requery(); 
Query.Locate('ID',ID,[]); 

before updating record to avoid error, but there has to be better solutions. Any ideas? Or should i move on to MyDAC or Zeoslib?

Best Solution

dbGO/ADO is the natural way to access MS-SQL databases. Are you sure that is the exact error message? Because I have never heard about it, but I have heard about "row cannot be located for updating".

That error message indicates that ADO can not find the record to be deleted or updated. Most often the cause is that the table does not have a primary key defined or there is at least no column in the table where the contents is all unique.

Make sure you define a primary key in your MS-SQL tables.