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

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

Post by Peter Kuhn » Sat, 03 Aug 2002 09:14:33



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.

 
 
 

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

Post by Sukesh Hooga » Sat, 03 Aug 2002 12:24:47


Peter

Possible solution is to delete records, disconnect the recordset (or close
and re-open the connection) and then issue database commands -
Pack etc.

Sukesh


Quote:> 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.


 
 
 

1. deleting records in a table and then adding new records

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.

2. How do i start sqlserveragent from the cmd line on win98

3. add records to access table fails with back cannot update read-only database

4. Zipping Backup Files as part Maint. Plan

5. cannot delete record from external table (.dbf file)..

6. US-MA-Developer - Oracle

7. Records cannot be deleted in forms or tables

8. Memory build up in Oracle 7.3.4 Win NT

9. Records cannot be deleted in forms or tables.

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

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

12. SQL7 server crawls (locks) when deleting records from a 3 million record table

13. add record to an empty table using RDO 2.0 and Visual basic 6.0