In classic ADO in VB6, in a recordset that's come from an external source, say, Set Rs = Conn.Execute("SELECT * FROM Table")
, each Field has an OriginalValue
property, so that after an update to a record you can still see what the original value of each field was.
However, I'm working with a recordset built like so:
Set Rs = New ADODB.Recordset
Rs.Fields.Append "Name", adVarChar, 100, adFldMayBeNull
Rs.Open
Rs.AddNew
Rs.Fields("Name").Value = "rudolph"
Rs.Update
But in this recordset, even if I change the value of a field, the OriginalValue property stays blank. Is there any way besides throwing the whole recordset to an XML stream, modifying the XML, and recreating the recordset to get OriginalValue to have the value I want?
I'm working with some previews of data changes where I have two recordsets, one representing the current values and one representing the original values. It's a pain, when needing to compare to see if something has changed, to have two objects instead of just one with two properties.
I know there is metadata inside a recordset about what its source table is, whether it's updatable, what the primary keys are, and what kind of properties the provider supports (such as NextRecordset
), but some of them could be hard to access in a fabricated recordset such as I'm working with.
Also, could some locking setting such as adLockBatchOptimi开发者_开发问答stic
somehow be needed?
Replace the line
rs.Update
with
rs.UpdateBatch
精彩评论