Results 1 to 5 of 5

Thread: deleting row only from recordset

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    New Delhi, India
    Posts
    75
    I have a recordset which contains 10 records. when i delete the fourth row using the delete method of the recordset, the row from the actual table is also getting deleted. how can i delete the row only from recordset and not from the actual table. any help?

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Question

    You can't. When you delete, edit, or add new records to the recordset, the changes are reflected in the table. Here I would suggest modifying your SQL statement so as to filter out the unwanted record - e.g. retrieve its autonumber and then filter or requery your recordset with a new SQL statement. With ADO use the filter method:
    Code:
    Dim MyID As Long
    
    MyID = myRS.Fields("IdRECORD").Value
    myRS.Filter = "IdRECORD <> " & MyID
    and with DAO just change the SQL.

  3. #3
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    transactions

    The best way of deleting the record from the recordset without deleting from the table immediately is using transactions -

    Code:
    cnTemp.BeginTrans
    
    rsTemp.Delete
    rsTemp.Update
    
    cnTemp.RollbackTrans
    where cnTemp is a connection object and rsTemp is a recordset object. The .RollbackTrans method cancels all database operations since the initial .BeginTrans. Transactions allow you to bundle a series of database operations together but not commit them until you're happy that everything is OK.

    To go ahead with the changes use .CommitTrans instead of rollback on the connection object. Remember that transactions are handled at the connection level.

    Hope this helps.
    That's Mr Mullet to you, you mulletless wonder.

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    You can also use a disconnected recordset....just don't reconnect back to your data source to perform the update

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    New Delhi, India
    Posts
    75

    Talking Thanx very much...

    thanx each one of u for u r help. it really helped me. paul's answer was very new to me and i thank him specially. for teaching new thing. thanx once again...

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