Cachedupdates problem

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jsantos98
Posts: 7
Joined: Tue 07 Oct 2008 11:29

Cachedupdates problem

Post by jsantos98 » Tue 07 Oct 2008 11:42

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

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 07 Oct 2008 13:42

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;

jsantos98
Posts: 7
Joined: Tue 07 Oct 2008 11:29

Post by jsantos98 » Tue 07 Oct 2008 14:18

How come that if I set UpdateAllFields to True everything works (without commitupdates)?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 07 Oct 2008 14:44

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.

jsantos98
Posts: 7
Joined: Tue 07 Oct 2008 11:29

Post by jsantos98 » Tue 07 Oct 2008 15:46

OK!

Thanks

Post Reply