Search code examples
sql-serverdelphidelphi-7ado

How to choose Delphi ADO Cursor location and Cursor Type


we have migrated a Delphi Project(Banking Application) from BDE to ADO and we have kept all the default properties as is and while unit testing there are issues.

One issue is "Row cannot be located for updating. Some values may have been changed since it was last read"

the Issue is coming while updating a table. Table employee is having Update trigger and it is updating same table(Employee) based on some checks.whether trigger updates the table or not system is throwing above error.

Most Suggested Solution : ADODataSet1.Properties['Update Criteria'].value :=adCriteriaKey; and it didnt work.

After googling we have come to know there are some properties like Cursor location and Cursor Type which are important while working with ADO.

we have just changed Cursor Location to clUseServer from clUseClient and it started working(magic) and we dont know why it is working.

now we are super confued what cursor location or Cursor type to use.

About My Application:

1) List view or DBGrid to show the records to user.

2) we are using data aware controls(more controls).

3) there are lots of inserts , updates and deletions

3) there are around 1000 users who uses this application.

4) Same user can work on same screen/Record.

after going through Client-Side Cursors Versus Server-Side Cursors we are planning to for Server Side cursors.


Solution

  • First of all I suggest you to forget the ADO and use FireDAC (or UniDAC)

    This problem occurs when you are using triggers or sometimes you set the default values for fields, because ADO can't find the Record you want to update it in Client-Side

    If you set the cursor location to Server-Side you will lose some good feathers like Local Sorting, Local Filtering and Local Indexes, your records will not keep on the Memory and speed of your DataSet will be decreased, Server-Side location also can have bad effects on Server's resources

    What RDBMS you are using ?

    You can create a Stored-Procedure and call it for updating and keep using the Client-Side Cursor Location

    Cursor-Location must be combined with a proper Cursor-Type to get a good result, this article will help you :

    http://etutorials.org/Programming/mastering+delphi+7/Part+III+Delphi+Database-Oriented+Architectures/Chapter+15+Working+with+ADO/Working+with+Cursors/