Ertugrul
Ertugrul

Reputation:

Row cannot be found for Locate?

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?

Upvotes: 2

Views: 2989

Answers (4)

user763539
user763539

Reputation: 3699

simple adotable1.refresh; after post should do the trick ...

Upvotes: 0

curious slab
curious slab

Reputation: 1160

In case anyone else has the same problem when using triggers, add SET NOCOUNT ON into beginning and SET NOCOUNT OFF into end of trigger.

Upvotes: 3

Tom
Tom

Reputation: 1381

The usual case for row cannot be updated is that you have default value constraints on the tables. Be sure to set values for the fields in OnNewRecord. You may also want to use myAdoDataset.Properties['Update Criteria'].Value := 0; Then ADO should use only the key for updates.

Upvotes: 0

Lars Truijens
Lars Truijens

Reputation: 43595

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.

Upvotes: 2

Related Questions