delphidbexpresstclientdataset

TClientDataSet used as in-memory dataset - is it possible to apply the updates in-memory without saving the data to a database?


By default, the TClientDataSet tracks all the changes made in the DataSet (inserts, updates, deletes). Is there a way to tell the dataset to accept the current changes (after a series of inserts using insert/post, let's say) without actually calling the database to save anything?

One idea that I thought of was to use a TDataSetProvider and implement the BeforeUpdateRecord event and set the Applied parameter to true. I don't like two things about this. I have to add two more objects (TDataSetProvider and the TSQLQuery object) and ApplyUpdates starts a transaction. Is there a simpler way?

If I don't set the ProviderName on the TClientDataSet, ApplyUpdates fails.

Thanks


Solution

  • You can set LogChanges to false before modifying the dataset. Alternatively, if you need the change log at any stage, you can call MergeChangeLog to incorporate updates.