打开 dBase 表

发布于 2024-10-25 19:20:12 字数 339 浏览 2 评论 0原文

我必须使用 ADOConnection 和 AdoTable 从旧 dBase 数据库复制一些信息。我可以打开所有表,但出现此异常

数据提供商或其他服务 返回 E_FAIL 状态

尝试打开 1.01 GB(1 093 588 624 字节)的大表时 。我注意到性能非常糟糕。这是连接字符串

  ConnectionString:=Format('Provider=Microsoft.JET.OLEDB.4.0;Data Source=%s;Extended Properties=dBase IV;',[path])

I have to copy some information from an old dBase database using ADOConnection and AdoTable. I am able to open all tables but I get this exception

Data provider or other service
returned an E_FAIL status

while trying to open a big table 1.01 GB (1 093 588 624 bytes). I note that the performance is very bad. this is the connection string

  ConnectionString:=Format('Provider=Microsoft.JET.OLEDB.4.0;Data Source=%s;Extended Properties=dBase IV;',[path])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薄情伤 2024-11-01 19:20:12

我相信 TADOConnection 的 CursorLocation 的默认设置是 clUseClient。通过该设置,整个数据集将由客户端读入内存。这可以解释缓慢的情况并可能解释错误。

尝试将其更改为clUseServer

ADOConn.CursorLocation := clUseServer;

或者您可以在对象检查器属性中更改它。

I believe that the default setting for CursorLocation with TADOConnection is clUseClient. With that setting, the entire data set is read into memory by the client. That would explain the slowness and may explain the error.

Try changing it to clUseServer.

ADOConn.CursorLocation := clUseServer;

Or you can change it in the object inspector properties.

A君 2024-11-01 19:20:12

这听起来像是标头中有一个自动打开(.MDX)索引标志,但数据库中不存在该索引。

您可以尝试此操作 - 它会清除数据库标头中的自动打开标志。 使用数据库的副本进行测试!!! 我尚未在 DBase IV 上进行测试,但它适用于 FoxPro 和 DBase 的多种版本。

procedure FixDBFHeader(const FileName: string);
var
  ByteRead: Byte;
  Stream: TFileStream;
begin
  Stream := TFileStream.Create(FileName, fmOpenReadWrite or fmShareDenyNone);
  try
    // Byte offset 28 has a value of 0x01 if a structural (auto-open) index exists,
    // or 0x00 if no such index exists. If the value is not set, we do nothing.
    Stream.Position := 28;
    Stream.Read(ByteRead, SizeOf(ByteRead));
    if ByteRead = 1 then
    begin
      ByteRead := 0;
      Stream.Position := 28;
      Stream.Write(ByteRead, SizeOf(Byte));
    end;
  finally
    Stream.Free;
  end;
end;

清除标头中的该标志后,您应该能够使用 ADO 或 Advantage Database Server(其本地服务器)打开 .DBF免费,并且支持 SQL。请注意,我与 Advantage 没有任何关系;我已经使用他们的产品处理旧版 DBF 文件很长时间了。

This sounds like it's got an autoopen (.MDX) index flag in the header, but the index doesn't exist in the database.

You can try this - it clears that autoopen flag in the database header. USE A COPY OF THE DATABASE TO TEST ON!!! I haven't tested on DBase IV, but it works on several flavors of FoxPro and DBase.

procedure FixDBFHeader(const FileName: string);
var
  ByteRead: Byte;
  Stream: TFileStream;
begin
  Stream := TFileStream.Create(FileName, fmOpenReadWrite or fmShareDenyNone);
  try
    // Byte offset 28 has a value of 0x01 if a structural (auto-open) index exists,
    // or 0x00 if no such index exists. If the value is not set, we do nothing.
    Stream.Position := 28;
    Stream.Read(ByteRead, SizeOf(ByteRead));
    if ByteRead = 1 then
    begin
      ByteRead := 0;
      Stream.Position := 28;
      Stream.Write(ByteRead, SizeOf(Byte));
    end;
  finally
    Stream.Free;
  end;
end;

After clearing that flag in the header, you should be able to open the .DBF with ADO or Advantage Database Server - their local server is free, and supports SQL. Note that I'm not affiliated with Advantage in any way; I've just used their product to work with legacy DBF files for a long time.

你与清晨阳光 2024-11-01 19:20:12

如果您仍然遇到 TAdoConnection 问题,我建议您使用 Apollo。这支持许多不同的表类型(Clipper NTX、Foxpro CDX)。

If you still have problems with TAdoConnection I would suggest Apollo. This supports many different table types (Clipper NTX, Foxpro CDX).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文