Results 1 to 3 of 3

Thread: want to delete ALL records in table...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    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?

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    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.

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width