We help IT Professionals succeed at work.

How to Reindex a DBF file Using VB6?

I had this question after viewing To Reindex DBF file Using VB6.
I think that the answer to above question is only demonstrate that Microsoft DAO 3.51 Object Library can index database file. However, if an index file is corrupted/damaged, the DAO won't work properly. Normally, I need to fix the damaged index file via "reindex" command using Foxpro. So, I would like to know if there is a way to do the reindex in VB6.

Best Regards
Ming
Comment
Watch Question

John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I think - since the index file is bad - the way to handle it is to first create an index file and then manipulate it if you want
Check this :  http://vbcity.com/forums/t/66952.aspx
Side Note : Dbase format is OLD...maybe you should consider another approach...like transfering your data to another database engine
Chayaphad ChokasutProgrammer

Author

Commented:
Dear John;

     Thank you for your kind solution. It's very helpful. I can now create new unique indexes by using VB6. However, if a new index is corrupt, do I have to delete it and recreate it again? or can I just directly reindex it in VB6? How could I do those?
     About new database engine, I always want to learn it. If possible, could you kindly provide some articles of new database engine that's compatible with VB6.
     Looking forward to your advices.

Best Regards
Chayaphad
John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
If it's corrupt you can't do much...so delete it and start over.
As for DB engine. VB6 works nicely with pretty much everything..so make your pick.
I reckon that ,based on the dbase background that Access or Sqlite are your best options
Chayaphad ChokasutProgrammer

Author

Commented:
Dear John

     Can I delete an index using .execute in VB6?  For example, I can create an unique index with command line
         aDatabase.Execute ("CREATE UNIQUE INDEX anIndexName ON aRecordset(aFieldName);")
     but when try to delete it with command line
         aDatabase.Execute ("DROP UNIQUE INDEX anIndexName ON aRecordset(aFieldName);")
     I got a syntax error. Please kindly help me with the correct syntax.

Best Regards
Ming
Programmer
Commented:
Dear John;

      After trial and error, I found the syntax for removing an index as below;
         aDatabase.Execute "DROP INDEX anIndexName ON aRecordset;"
      I also already tested fixing a damaged index by removing and recreating a new one. It works.

Best Regards
Chayaphad