TClientDataSet用作内存中的数据集-是否可以在不将数据保存到数据库的情况下应用内存中的更新? [英] TClientDataSet used as in-memory dataset - is it possible to apply the updates in-memory without saving the data to a database?

查看:93
本文介绍了TClientDataSet用作内存中的数据集-是否可以在不将数据保存到数据库的情况下应用内存中的更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,TClientDataSet跟踪在DataSet中所做的所有更改(插入,更新,删除)。有没有一种方法可以告诉数据集接受当前的更改(在使用插入/发布进行一系列插入之后),而无需实际调用数据库以保存任何内容?

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?

我想到的一个想法是使用TDataSetProvider并实现BeforeUpdateRecord事件,并将Applied参数设置为true。我不喜欢这两件事。我必须添加两个对象(TDataSetProvider和TSQLQuery对象),ApplyUpdates将启动一个事务。有没有更简单的方法?

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?

如果我未在TClientDataSet上设置ProviderName,ApplyUpdates将失败。

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

谢谢

推荐答案

您可以设置 LogChanges 设置为false,然后再修改数据集。另外,如果您在任何阶段都需要更改日志,则可以调用 MergeChangeLog 合并更新。

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.

这篇关于TClientDataSet用作内存中的数据集-是否可以在不将数据保存到数据库的情况下应用内存中的更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆