Index does not exist and Record/Key deleted exceptions

I've finally found a solution to a problem that's been bothering me for
a while.  Although it's apparently been addressed many times, I haven't
seen it explained this way anywhere else, so I'm posting here in the
hopes it's of use to someone.  My apologies if this is obvious to
others, but it confused me for a while.

I have an old application that's been using a DBGrid component to edit
various Tables stored in Paradox files.  The DBGrid pointed to a
DataSource which pointed to a Table.  Since the user could switch back
and forth between tables, I merely changed the name of the file in the
Table component and everything worked okay.  The problem started when I
added indexes.  I added a primary and secondary indexes every time a
file was opened, but still sometimes got the error "Index does not
exist".  To get rid of this, I started deleting the indexes every time
the file was closed, but then had intermittent problems with other
exceptions, especially when trying to edit fields in the index.

The solution was to NOT use a single table for all of the editting.
Instead, every time I edit a file, I create a new Table, change the
DataSource to point at it, and add the indexes.  When finished editing a
file, I destroy the Table.  I think Delphi/BDE was getting confused when
adding and then deleting indexes to the same Table repeatedly.

In hind sight, this is the way you should DataSources anyway, I guess.

--
Michael Schweighardt                 mailto:micha...@qcc.sk.ca
http://www.qcc.sk.ca/personnel/michaels     QCC Communications
office: (306) 249-0220 Innovation Place, Saskatoon, SK, Canada