使用 TADOQuery 查询 TClientDataSet
我的问题很简单。我有一个通过 TDataSetProvider 链接到 TADOQuery 的 TClientDataSet。我可以将数据从 TADOQuery 放入 TClientDataSet,但是如何将数据从 TClientDataSet 取回到 TADOQuery?
当我运行查询并将 TClientDataSet 的 Active 属性设置为 True 时,数据会自动从 TADOQuery 传输到 TClientDataSet,但是如果我停用 TADOQuery 然后再次激活它,如何从 TClientDataSet 取回数据?
我在多个数据库上运行相同的查询并使用 TClientDataSet 连接结果。这工作正常。我现在的问题是,我需要将连接的结果集从 TClientDataSet 返回到 TADOQuery 中,以便我可以使用 TADOQuery 的 SaveToFile 过程(出于兼容性原因)。我该怎么做?
My question is very simple. I have a TClientDataSet that is linked to a TADOQuery via a TDataSetProvider. I can put data into the TClientDataSet from the TADOQuery, but how do I get data from the TClientDataSet back into the TADOQuery?
Data is automatically transferred from the TADOQuery to the TClientDataSet when I run a query and then set the TClientDataSet's Active property to True, but if I deactivate the TADOQuery and then activate it again, how can I get the data back from the TClientDataSet?
I am running the same query on several databases and using the TClientDataSet to concatenate the results. This is working fine. My problem now is that I need to get the concatenated result set back from the TClientDataSet into the TADOQuery so that I can use the TADOQuery's SaveToFile procedure (for compatibility reasons). How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不像使用 dbExpress 那样使用 TADOQuery,但我想需要使用相同的技术。将更改发布到 TClientDataSet 后,调用“ApplyUpdates (0)”,它将数据从 clientdataset 传输到其提供者。
I don't do TADOQuery as I use dbExpress, but I imagine that one needs to use the same technique. After you have posted your changes to TClientDataSet, call 'ApplyUpdates (0)', which transfers the data from the clientdataset to its provider.
您始终可以将数据集写回临时表,然后查询它。哎哟!!
You could always write the dataset back out to a temp table and then query it. Ouch!!
我刚刚调查完这个。我的应用程序允许用户通过查询数据库来生成报告。我可以让它工作,并且对于小型结果集非常有效 - 但是,由于这是一个报告应用程序,并且完全有可能返回数十万条记录,因此使用 ClientDataSet 会带来巨大的性能问题。一旦您获得超过大约 50,000 条记录(考虑到客户群,这是合理的),处理量就会开始呈指数级增长,因此现在这基本上没有实际意义。
I've just about finished looking into this. My application allows the user to generate reports by querying their databases. I can get this to work and it is very efficient for small result sets - however, as this is a reporting application, and it's entirely possible that hundreds of thousands of records can be returned, using a ClientDataSet gives massive performance problems. Once you get above around 50,000 records (reasonable, given the customer base), processing starts to increase exponentially, so this is now basically moot.