Delphi:使用 TClientDataset 作为内存数据集 [英] Delphi: using TClientDataset as an in-memory dataset

查看:25
本文介绍了Delphi:使用 TClientDataset 作为内存数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据this page,可以使用TClientDataset 作为内存数据集,完全独立于任何实际的数据库或文件.它描述了如何设置数据集的表结构以及如何在运行时将数据加载到其中.但是当我尝试按照 D2009 中的说明进行操作时,第 4 步 (table.Open) 引发了异常.它说它没有指定提供者.

According to this page, it's possible to use TClientDataset as an in-memory dataset, completely independent of any actual databases or files. It describes how to setup the dataset's table structure and how to load data into it at runtime. But when I tried to follow its instructions in D2009, step 4 (table.Open) raised an exception. It said that it didn't have a provider specified.

该页面上示例的重点是构建不需要提供程序的数据集.页面是否错误,是否已过时,或者我在某处遗漏了一步?如果页面错误,我需要使用什么来创建一个完全独立的内存数据集?我一直在使用 TJvMemoryData,但如果可能的话,我想减少我的数据集添加到我的项目中的额外依赖项的数量.

The entire point of the example on that page is to build a dataset that doesn't need a provider. Is the page wrong, is it outdated, or am I missing a step somewhere? And if the page is wrong, what do I need to use instead to create a completely independent in-memory dataset? I've been using TJvMemoryData, but if possible I'd like to reduce the amount of extra dependencies that my dataset adds into my project.

推荐答案

在运行时您可以使用 table.CreateDataset 或者如果这是在设计图面上,您可以右键单击 CDS 并单击创建数据集.不过,您需要先为 CDS 指定列/类型,然后才能执行此操作.

At runtime you can use table.CreateDataset or if this is on a design surface you can right click on the CDS and click create dataset. You need to have specified columns/types for the CDS before you can do this though.

这篇关于Delphi:使用 TClientDataset 作为内存数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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