CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2001
    Posts
    14

    Deleting records in a recordset

    Hey everyone, I'm trying to delete all the records in a table using a while loop. When I executed the following code it deletes two records (out of 300) and immediately encounters EOF and exits the loop. I'm using ado...and I can't figure out why this isn't working.



    set rsPic = new ADODB.Recordset
    rsPic.Open "SELECT * FROM [PIC]", adCnGLC, adOpenDynamic, adLockOptimistic, _
    adCmdText

    If rsPic.BOF <> true then
    rsPic.MoveFirst
    Do While (Not rsPic.EOF)
    rsPic.Delete
    rsPic.MoveNext

    DoEvents
    Loop
    End If





  2. #2
    Join Date
    Apr 2001
    Posts
    23

    Re: Deleting records in a recordset

    What is the Do Events statement for?


  3. #3
    johnpc7 Guest

    Re: Deleting records in a recordset

    What is the Do Events statement for?


  4. #4
    Join Date
    Apr 2001
    Posts
    14

    Re: Deleting records in a recordset

    To yield control back to VB so it can update the gui - and do whatever other processing it does.


  5. #5
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Deleting records in a recordset

    WHy are you deleting in the loop? Why not to delete everything in 1 SQl
    SQL = "DELETE FROM [PIC]"
    Conn.Execute SQL

    where Conn is your connection

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured