Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > Files Directories Drives sample source codes
Loading and saving ADO recordsets to XML files
Loading and saving ADO recordsets to XML files The following routines show how to load and save ADO recordsets to XML files: 'Purpose : Loads an ADO recordset from an XML file 'Inputs : sPath The path and file name of the XML file. 'Outputs : Returns a copy of the recordset on success, or nothing on failure. Function RsLoadFromXML(sPath As String) As Recordset Dim oStream As ADODB.Stream, oRsLoad As ADODB.Recordset On Error GoTo ErrFailed Set oRsLoad = New ADODB.Recordset oRsLoad.CursorLocation = adUseClient Set oStream = New ADODB.Stream 'Load stream oStream.LoadFromFile sPath 'Open recordset using stream oRsLoad.Open oStream Set RsLoadFromXML = oRsLoad Set oStream = Nothing Set oRsLoad = Nothing Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False Set RsLoadFromXML = Nothing End Function 'Purpose : Saves an ADO recordset to an XML file 'Inputs : sPath The path save the XML file to. 'Outputs : Returns True on success, else returns False Function RsSaveToXML(oRsSave As Recordset, sPath As String) As Boolean Dim oStream As ADODB.Stream On Error GoTo ErrFailed 'Create stream Set oStream = New ADODB.Stream 'Save recordset to stream oRsSave.Save oStream, adSaveCreateOverWrite 'Save stream to file oStream.SaveToFile sPath Set oStream = Nothing RsSaveToXML = True Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False RsSaveToXML = False End Function
Privacy Policy
|
Link to Us
|
Links