我必须使用dBase和AdoTable从旧的ADOConnection数据库中复制一些信息。我能够打开所有的表,但是我得到了这个异常。
数据提供程序或其他服务返回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])发布于 2011-03-24 14:41:03
我相信CursorLocation和TADOConnection的默认设置是clUseClient。在这种情况下,整个数据集由客户端读取到内存中。这将解释缓慢,并可能解释错误。
尝试将其更改为clUseServer。
ADOConn.CursorLocation := clUseServer;或者可以在“对象检查器”属性中更改它。
发布于 2011-03-24 15:02:24
这听起来像是头中有一个自动打开(.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或优势数据库服务器打开优势数据库服务器--它们的本地服务器是免费的,并且支持SQL。注意,我在任何方面都不附属于Advantage;我只是使用他们的产品来处理遗留的DBF文件很长时间了。
发布于 2011-03-24 14:56:48
如果您对TAdoConnection仍有问题,我建议使用阿波罗。这支持许多不同的表类型(Clipper NTX,Foxpro CDX)。
https://stackoverflow.com/questions/5420760
复制相似问题