delphi-2010 - 没有客户端数据集的 dbgrid

标签 delphi-2010 dbexpress delphi

我有一个带有 dbgrid 和 sqlquery 组件的表单。我正在尝试用 sqlquery 填充 dbgrid。当我这样做时,我收到消息“单向数据集上不允许操作”。我不想使用客户端数据集,因为我不需要数据的“本地”副本,我想直接读取和显示数据。如何做到这一点?

最佳答案

documentation明确指出(强调):

TSQLQuery is a unidirectional dataset. Unlike other datasets, unidirectional datasets do not buffer multiple records in memory. Because of this, you can only navigate using the First and Next methods. There is no built-in editing support: you can only edit the data in an SQL query by explicitly creating an SQL UPDATE command or by connecting the dataset to a client dataset using a provider.

因为没有多条记录的缓冲,除了向前你不能向任何方向移动,这意味着 DBGrid 不能显示多行或支持滚动。

(事实上,根据 Types of DBExpress DataSets 上的文档,所有 DBExpress 组件都是单向的。)

您必须使用 TClientDataSet 或从使用 DBExpress 更改为其他访问数据的方法,例如 ADO ,或使用 TDBGrid 以外的其他方式(如 TStringGrid)显示数据并实现您自己的内部存储。但是,TClientDataSet 不必是磁盘文件,如果您检索的数据量在内存中是可管理的;所有数据都可以保留在那里,而不是“本地副本”(“内存数据集”)。

关于delphi-2010 - 没有客户端数据集的 dbgrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15726347/

相关文章:

delphi - 如何在不使用 alClient 对齐的情况下调整 TGridPanel 内 TEdit 的大小

Delphi IDE 由于隐藏的模式窗口而锁定

delphi - 在 Windows 中存储密码的安全方法

delphi - 如何使用 dbExpress 从 Firebird 获取表描述(字段和类型)

delphi - 在 ibm bluemix 中运行 Windows 应用程序

delphi - 是否可以在运行时在最小化,最大化和关闭按钮附近向TF​​orm标题添加自定义按钮?

mysql - 将 MySQL 应用程序从 Delphi 2006 升级到 2010 时出现问题

sql - Delphi DBExpress/Firebird 参数化查询中的字符串截断错误

Delphi 和 Lazarus 均已安装

c# - 寻找 GSM 短信组件/ActiveX