deleting records in a table and then adding new records

deleting records in a table and then adding new records

Post by William F. LaMarti » Thu, 16 Mar 2000 04:00:00



I am accessing an Access database table via a VB program and displaying its
records in a data grid on a form.  One of my procedures consists of deleting
all the records of this particular table in the database , and immediately
repopulating the table with new records.

My problem is that occasionally, the repopulated table does not display,
say, the first 20 of its records in the data grid view. But when I check the
table in Access all the new records are there.  But there is a catch: the
table is really corrupted, for if you "repair" the database, this table now
only contains the fewer number of records that were displaying the in the
repopulated data grid.

I delete the records with the following code:

    Dim DBtemp As dao.Database
    Set DBtemp = OpenDatabase(WF) 'the working file
    DBtemp.Execute "delete * from invoices_pending"
    DBtemp.Close
    Set DBtemp = Nothing

and then immediatly repopulate the table via more code.

Could my problem be that the above deletion process doesn't finish before
the repopulation starts, resulting in the first 20 ro so new records not
really being recorded?

This is a bit hard to debug, since the problem occurres erratically.  I have
put a pause in between the deletion and repopulation of the table, and it
seems to cure the problem. But I have thought that I had the problem cured
before only to have it come back.

 
 
 

1. Cannot add record to Visual Foxpro table after deleting all records in table

After:
1. opening adodb connection with
vfpoledb.dll and datasource=path$ &
foxprofile.dbc successfully
2. deleting all records from table1 in
foxprofile.dbc successfully with
connection.execute("delete from table1") (I
can see the records being marked as deleted
in the VFP IDE) ,

I cannot add any record to table1 that has a
primary key like one of the deleted records.
So I execute connection.execute("pack
table1") and get "ADO error: File is in use".
(but my foxpro IDE is closed and only my VB6
program has the *.dbc open).

How can I delete (and pack if necessary) all
the records so they are gone for good from
the table?

Please!
Thank you.

2. help needed with oci jdbc driver on Oracle 8.1.5

3. Adding a new record to a table after a delete

4. Need help with the union operator

5. ADO2.5, can't add new record to an empty table using record binding

6. Synonym Performance

7. adding new records & new record

8. Jobs, TSQL (SP) and success/failure codes

9. Deleting Records and adding records

10. Adding records vs. Deleting records

11. Adding record in detail table or create a new master table for it

12. Deleting all records then adding new ones in a single update

13. FILTER PORTAL RECORDS - DISABLE ADDING NEW RECORDS IN A PORTAL