|
-
Aug 9th, 2000, 06:03 AM
#1
Thread Starter
Lively Member
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?
-
Aug 9th, 2000, 09:28 AM
#2
Hyperactive Member
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.
-
Aug 9th, 2000, 09:51 AM
#3
Hyperactive Member
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.
-
Aug 9th, 2000, 11:12 AM
#4
Guru
You can also use a disconnected recordset....just don't reconnect back to your data source to perform the update
-
Aug 10th, 2000, 02:38 AM
#5
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|