# Re: VB6与DBF资料库可否建立或使用索引...如何做？？

Posted by wave on November 18, 1999 at 15:34:21:

In Reply to: VB6与DBF资料库可否建立或使用索引...如何做？？ posted by Aaron on November 17, 1999 at 15:09:46:

目前个人测试ADO无法使用DBF索引档,但ACCESS之.MDB可以使用索引,从我收集的资料中(//WWW.MICROSOFT.COM/DATA/ADO/ADOTECHINFO/DAO2ADO_3.HTM)也显示索引是FOR Microsoft Jet database only,亦即只有access档可以用.
另一个使用DBF索引方式可用DAO,如下例:
DIM MYDB AS DATABASE
DIM MYRS AS RECORDSET
SET MYDB = OPENDATABASE("C:\TEST",FALSE,FALSE,"DBASE III;")
SET MYRS = MYDB.OPENRECORDSET("AAA")
MYRS.INDEX = "A1"
此例可在C:\TEST目录开启AAA.DBF资料库,并设索引为A1.NDX,同时注意在C:\TEST目录下必须有一档案AAA.INF其内容为
NDX1=A1.NDX
要产生一索引可用sql语法如mydb.execute "create index a2 on aaa ([栏位名称1],[栏位名称2])"
必须注意a2.ndx档案不可存在,否则会产生错误.执行后AAA.INF档案内容变为
NDX1=A1.NDX
NDX2=A2.NDX

Follow Ups: