PDA

Click to See Complete Forum and Search --> : want to delete ALL records in table...


Pallex
May 14th, 2000, 09:11 PM
have tried

----

strSQLOut = "select * from DAILY_RET"
rsTableOut.Open strSQLOut, cnDataBaseOut, adOpenKeyset, adLockOptimistic

While rsTableOut.RecordCount > 0
rsTableOut.Delete adAffectCurrent
Wend

rsTableOut.Close

----

which works in another program i`m maintaining, but not in this one! the error is in the line doing the deleting... .RecordCount is not null... error is `Errors occured` - number is 80040e21

any ideas?

Pallex
May 14th, 2000, 09:30 PM
um...despite the `helpful` error message, i`ve worked it out..the code i borrowed the subroutine about from only selected 1 record at a time...so when i changed my code to :

While rsTableOut.RecordCount > 0
rsTableOut.Move rsTableOut.RecordCount - 1, adBookmarkFirst
rsTableOut.Delete
Wend

it works fine! doh!

a.

Clunietp
May 15th, 2000, 12:47 AM
That will be slow, compared to a simple SQL statement:
Delete from MyTable

If you are using SQL Server, you can perform this even faster using
Truncate table MyTable
this does not record each delete in the transaction log, so its very fast

HTH

Tom