Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Visual Basic Programming Code Examples

Visual Basic > Database SQL Stuff Code Examples

Cloning or copying an ADO recordset

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
Cloning or copying an ADO recordset The code below shows how to copy/clone an existing ADO recordset. This functionality can be useful if you want to keep an copy of the data before the user makes any changes (note, you can also use the oRs.Fields(x).OriginalValue property for this). 'Purpose : Creates a copy an existing client side ADO recordset 'Inputs : oRs The recordset to copy 'Outputs : Returns a copy of the recordset on success, or nothing on failure. 'Notes : Function RsClone(oRs As ADODB.Recordset) As Recordset Dim oStream As ADODB.Stream, oRsClone As ADODB.Recordset On Error GoTo ErrFailed If oRs.CursorLocation = adUseClient Then Set oStream = New ADODB.Stream oRs.Save oStream, adPersistXML Set oRsClone = New ADODB.Recordset oRsClone.Open oStream Set oStream = Nothing Set RsClone = oRsClone Set oRsClone = Nothing Else Debug.Print "Must use client side recordsets..." Debug.Assert False End If Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False Set RsClone = Nothing End Function