Results 1 to 2 of 2

Thread: Delete Record in Recordset by Row Number

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2013
    Location
    Minneapolis, MN
    Posts
    531

    Delete Record in Recordset by Row Number

    Hello:

    I would like to delete a row in a RecordSet using old school ADODB. Basically, I am deleting rows in a DataGridView, and after deleting various rows I do an update to preserve the order. The problem is, if there were more records to start with, the records at the end need to be deleted.

    Code:
                If rs.RecordCount > ccnt Then
                    For cx As Integer = ccnt To rs.RecordCount
                        ' Delete row cx
                        ' rs.Update()
    
                    Next
    
                End If
    Hopefully this is an easy question. I have done numerous web searches, including this: https://flylib.com/books/en/3.9.1.26/1/

    Things are not obvious.

    Thank you!
    - A 'Hyperactive Member' trying to make a difference in a hyperactive world! And recently, I've been promoted to a 'Finatic Member,' whatever that means!

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: Delete Record in Recordset by Row Number

    Is there a really good reason for using old school ADODB? It's easy enough to work with positions as seen in the following code which is part of the code sample for moving rows up/down in a DataGridView. The code is demonstrated using ms-access but will work for any database as all you need is a column to store row position.

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