如何以原生方式读写 dbf?
在Delphi for Win32中,如何在没有BDE的情况下以本机方式读写dbf文件?我知道网络上有一些可用的组件,但我从未使用过其中任何一个,所以我不知道该选择哪个(如果有的话)。
In Delphi for Win32, how to read and write a dbf file in a native way, without the BDE? I know there are some components available in the web, but I have never used any of them, so I don't know which to choose (if any).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以使用 ADO 访问 DBF 文件,
请参阅示例代码(使用
TAdoConnection< /code>
和
TAdoDataSet
组件)。You can use ADO to access a DBF File
See ths sample code (using an
TAdoConnection
andTAdoDataSet
components).当我还在处理 DBF 文件(一些旧版应用程序)时,我使用了 TDBF 。我仍然使用它来维护这些应用程序。它是免费的,有很多功能并且运行良好。
I used TDBF back when I was still working with DBF files (some legacy apps). I still use it for maintainance of those apps here and there. It is free, has a lot of features and works good.
在开始使用 Firebird 之前,我使用 Software Science 中的 Topaz 已有多年。它始终是一个优秀的库,有很棒的手册和良好的技术支持。它支持索引,甚至有内存选项。我认为这将是一个不错的选择。
I used Topaz from Software Science for many years before I got started with Firebird. It was always an excellent library, had a terrific manual and good technical support. It supports indexes and even has an in-memory option. I think it would be a good choice.
Apollo 数据库 VCL。
Apollo Database VCL.
ADO 对我不起作用,但我设法使用 BDE 打开我的 dbf 文件:
从数据访问(或 BDE,取决于您的 Delphi 版本)部分,我放置了 TDataBase 和 TTable 组件(如果需要,您可以使用 TQuery )。
通过双击 TDataBase 组件,我打开了设置对话框。用“db_name”填充名称字段(名称是任意的),驱动程序名称=“STANDARD”,参数字段:“PATH=C:\Path\To\DBF_FILES\”。
然后我设置 Connected=True。
然后在 TTable 组件中我设置 DatabaseName = 'db_name' - 我在 TDataBase 组件中设置的那个。并将 TableName 属性设置为位于指定文件夹中的“DB_FILE.dbf”。
有效 = 真。
你知道下一步该做什么
ADO didn't work for me but I managed to open my dbf file using BDE:
From a Data Access (or BDE, depends on your version of Delphi) section I put a TDataBase and, TTable components (you can use TQuery if you want).
By doubleclick on TDataBase component I opened the setup dialog. Filled the Name field with 'db_name' (the name is arbitrary), driver name = 'STANDARD', Parameters field: 'PATH=C:\Path\To\DBF_FILES\'.
Then I set Connected=True.
Then in TTable component I set DatabaseName = 'db_name' - the one I set in TDataBase component. And TableName property set 'DB_FILE.dbf' which was located in the specified folder.
Active = True.
You know what to do next
如果不需要索引,读取 DBF 文件并不难。格式非常简单。后面是固定大小寄存器的标头。每个寄存器中都有一个标志来指示它是否被删除。我建议寻找一个可以满足您需求的组件。您可以在 Torry 的 Delphi 页面中找到一些内容。
It is not hard to read a DBF file if you don't need indexes. The format is pretty straightforward. A header followed for fixed sized registers. There is a flag in each register which indicates if it is deleted or not. I suggest looking for a component which does what you want. You can find some in Torry's Delphi pages.
你可以尝试这个简单的方法
You can try this simple way