DELPHI4的数据库索引再次求助??

ahu 2000-01-19 11:23:00

我已参照kxy 所给方案在表中新增了一个"+"类型的字段,并使其作为key,但问题依然存在。在程序中使用了多页面,第一页是数据增加,第二页是数据
查询,程序片段如下
1.点击第一页上"保存按钮"
table1.indexname:='';
table1.cancelrange;
table1.append;
table1['callno']:=edit1.text;
table1['departno']:=edit2.text;
...
table1.post;

2.选择第二页面时
with table1 do
begin
indexname:='bbcallno';
setrangestart;
fieldbyname('callno').asstring:=edit1.text;
setrangeend;
fieldbyname('callno').asstring:=edit1.Text;
applyrange;
end
问题如下:
1.按以上程序运行时,当在第一页中增加一数据后,再到
第二页查询时,出现"index out of date" 错
2.若将保存子程序中table1.indexname:=''去掉,则在第
一页点击"保存"时,出现" index is readonly"错
3.数据增加时,所有的索引都会更新吗?
4.如何读取foxpro中dbf表的复合索引(cdx)?

表中各字段取值均有可能重复,还有更好的方案吗?
烦请赐教,不胜感激!

ahu
20000.01.19
...全文
127 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
kxy 2000-01-19
  • 打赏
  • 举报
回复
1)建第二索引时,要选中Maintained.
1.2.都是由它所引起.
3.是的,BDE会自动处理.(要选中Maintained.)
Datebase Desktop中的help

Maintained

Specifies whether to maintain the secondary index automatically.

Maintained indexes are updated by Database Desktop every time the table changes.
This speeds up certain operations like queries.
Maintained indexes are available for keyed tables only.
Non-maintained indexes are updated only when the index is used; for example, when you link tables or run a query.
The operation that uses the secondary index takes slightly longer using a non-maintained index, because Database Desktop must first update the index to recognize values that you have added, deleted, or changed, and then sort the table according to the new index. Also, if a non-maintained index becomes out of date, you cannot use it to change the viewing order of records.

Non-maintained indexes are most useful on tables that are read-only.
4)yjq说的对,不过有些dbf的索引,delphi并不支持.
5)我写了一个例子发给你.
渤海海峡 2000-01-19
  • 打赏
  • 举报
回复
cdx索引在table.indexfiles中设定。然后在table.indexfieldnames中使用。

2,496

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧