Page 1 of 1

Cachedupdates problem

Posted: Tue 07 Oct 2008 11:42
by jsantos98
Hi!

I'm currently upgrading a work project from BDE/ADO to SDAC and it's almost finished, however, I've found a problem...

The project uses extensivelly CachedUpdates.

Using the same form and without exiting it, I'm changing some values (integers), something like:
Initial Value : 1
Change to 2
ApplyUpdates
DBMonitor reports the change
Change to 3
ApplyUpdates
DBMonitor reports the change
Change to 1
ApplyUpdates
Nothing reported in DBMonitor

After some investigations, I've found out that this only occurs when the value is set to the original one...
I've managed to make a workaround using UpdateAllFields option set to true, however, I don't want to use this workarround because it will try to update all fields when only one was changed and because I would have to change more then 800 datasets!

I'm using version 4.50.0.39 22-Sep-08 (Source code version acquired 15 days ago)

Thanks

Posted: Tue 07 Oct 2008 13:42
by Dimon
ApplyUpdates writes a dataset's pending cached updates to a database. This method passes cached data to the database for storage, but the changes are not committed to the database.
You should call the CommitUpdates method to commit the changes to the database and to clear the cached update buffer, like this:

Code: Select all

  MSQuery.ApplyUpdates;
  MSQuery.CommitUpdates;

Posted: Tue 07 Oct 2008 14:18
by jsantos98
How come that if I set UpdateAllFields to True everything works (without commitupdates)?

Posted: Tue 07 Oct 2008 14:44
by Dimon
When UpdateAllFields is set to True on executing ApplyUpdates a query that includes all fields is created and executed.
But when UpdateAllFields is set to False query is created only for the changed fields. And if you don't call CommitUpdates then cached buffer isn't cleared, and when you set the field value to the original value then no files are considered as changed.

Posted: Tue 07 Oct 2008 15:46
by jsantos98
OK!

Thanks