TDataset 和 TMemDataset
我需要迭代多个 MySQL 查询并将它们保存在 TMemDataset
数组中。这似乎可以做到这一点:
MemDataset1.CopyFromDataset(ZQuery1,True);
但是,每次查询更改时,所有先前的 TMemDataset 都会更改为包含新值(我猜是因为它们是“数据感知组件”)。如果我使用 ZQuery1.Free
删除 ZQuery1
,那么所有数据都会消失。我该如何避免这种情况?
我正在使用 FreePascal,但我打赌 Delphi 的解决方案也适用。
I need to iterate through a number of MySQL queries and save them in an array of TMemDataset
's. This seems to do it:
MemDataset1.CopyFromDataset(ZQuery1,True);
However each time the query changes, all the previous TMemDataset
's are changed to contain the new values (I guess because they are "data-aware components"). If I get rid of ZQuery1
with ZQuery1.Free
, then all of the data vanishes. How do I avoid this?
I am using FreePascal, but I bet the solution for Delphi would apply too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是拥有一个
ZQuery
数组以及一个MemDataSet
数组。类似的东西应该可以工作,因为现在查询和内存数据集之间不再存在混淆。
The solution is to have an array of
ZQuery
as well as an array ofMemDataSet
Something like that should work, because now there's no more confusion between the Queries and the memdatasets.