To Reindex DBF file Using VB6

How to Reindex a DBF file Using VB6 ?
If anyone knows please send me with description and with an example.
chidu75Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kulyasaCommented:
If you are using dbf files in your application you can use index files - .idx, .cdx for FoxPro, .ntx for dBASE. You specify index files in an .inf file, which you can create by making a text file with the same file name as your database and appending an .inf extention.

Create a FoxPro table ABC.DBF with two fields - NAME(C,10) and NUMBER(N,3). Add some records:
For example:
NAME       NUMBER
John         2
Andrew       3
Michael      1

Create an index file ABC.IDX for field NAME.
Create the text file ABC.INF in the directory that contains ABC.DBF. On the first line add the database type, in the second - name of the index file:
[FoxPro 2.5]
IDX1=abc.idx

Create new Project in VB6.
Add reference to DAO: Project->References->Microsoft DAO 3.51 Object Library.
Paste the following code into form code.

Private Sub Form_Load()
Dim dbsFox As Database
Dim Rst As Recordset
Set dbsFox = opendatabase("D:\", False, False, "FoxPro 2.5;")
Set Rst = dbsFox.openrecordset("ABC")
With Rst
.Index = "ABC"
.MoveFirst
Do Until .EOF()
   Debug.Print !Name
   .MoveNext
Loop
Debug.Print

.AddNew
!Name = "Keith"
.Update

.MoveFirst
Do Until .EOF()
   Debug.Print !Name
   .MoveNext
Loop
End With
End Sub

As you can see Microsoft Jet handles your index file correctly and reindexes database file when you delete, update or add records.

Good luck
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DanRollinsCommented:
Hi chidu75,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept kulyasa's comment(s) as an answer.

chidu75, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
NetminderCommented:
Per recommendation, force-accepted.

Netminder
CS Moderator
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.