如何实现独立的克隆TADODataSet? [英] How to achieve independent cloned TADODataSet?

查看:236
本文介绍了如何实现独立的克隆TADODataSet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况如下:



我们有一些SQL表。我们在这个表上执行SQL查询,我们在TADOQuery对象中有结果。

  var 
qryOryginal,qryClone: TADOQuery;

begin
//设置所有的东西
qryOryginal.Active:= True;
qryClone.Clone(qryOryginal,ltBatchOptimistic);
qryOryginal.Delete; //在qryOryginal中删除qryClone删除其记录!
结束因此,克隆DataSet之后,我的qryClone应该保存和独立的数据(至少我以为是这样)。但是,执行qryOryginal上的Delete会对qryClone造成相同的操作。我不想要。



任何想法?



我知道我可以将数据存储在其他地方, TClientDataSet或许,但我想先尝试以上解决方案。



提前感谢您的时间。

解决方案

克隆只将光标克隆在数据集上,而不会复制数据集中保存的数据。



如果需要有两个独立数据,那么您必须将数据从原始数据集复制到第二个数据集。



如果要在不更改数据集上的当前光标的情况下读取或修改单个数据集,那么您可以使用克隆方法。


The scenarios is like this:

We have some SQL table. We are performing an SQL query on this table and we have results in TADOQuery object.

var
  qryOryginal, qryClone: TADOQuery;

begin
  //setup all the things here
  qryOryginal.Active := True;
  qryClone.Clone(qryOryginal, ltBatchOptimistic);
  qryOryginal.Delete; //delete in qryOryginal casues that qryClone deletes its record too!
end;

So, after cloning the DataSet my qryClone should hold and independent data(at least I thought so). However, performing Delete on qryOryginal causes the same operation on the qryClone. I don't want that.

Any ideas?

I know I could store the data elsewhere, in TClientDataSet perhaps but I would like to try the above solution first.

Thanks in advance for your time.

解决方案

Cloning just clones the cursor on dataset, not duplicating the data kept in the dataset.

If you need to have two independent data, then you have to copy the data from the original dataset to the second one.

If you want to read or modify a single dataset without changing the current cursor on the dataset, then you can use Clone method.

这篇关于如何实现独立的克隆TADODataSet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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