我正在使用Delphi 2007连接到旧的FoxPro 2.6表 我安装了BDE,并在表单上放了一个TTable。
一张桌子不起作用
将databasename
设置为c:\datadir
和
表名为contacts.dbf
。
当我将active设置为true时,我得到了
无效的索引描述符。
另一张表格正常
我有另一个名为article.dbf
的表,可以很好地加载,在原始程序中一切正常。
这是我尝试的内容
我已经重新索引了原始程序中的所有内容,但这没有任何区别
事实上,Foxpro的诊断说一切都很好
我并不关心任何索引,因为表中没有那么多记录
我已经尝试设置indexfile
属性,但这没有帮助。
如何让Delphi连接到表并停止抱怨索引?
答案 0 :(得分:3)
您的contacts.dbf表可能包含BDE无法评估的表达式索引。以下是我发现here
的解释问题:什么类型的FoxPro索引 BDE不支持?什么时候 试图打开一些桌子,我得到一个 “索引描述符无效”错误。
答案:当发生此错误时 生产指数(.CDX)相关联 table有一个索引标记,其中包含 BDE不能表达的表达方式 评估。解决方案是删除 使用FoxPro创建的标记 BDE可以的等价指数 理解。
以下条件不是 由BDE支持并将导致 “索引描述符无效”错误。
不支持DTOC(,1)格式;使用 DTOC()。 ALLTRIM功能没有 支持的;使用LTRIM(RTRIM(Field))。
答案 1 :(得分:2)
这是Sertac描述的代码,它将从标题中删除自动打开的CDX标志。 首先制作数据库的副本。当然。
var
Stream: TFileStream;
ByteRead: Byte;
begin
Stream := TFileStream.Create("YourFile.dbf", 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;