VB6 RecordSet与XML转换

前端之家收集整理的这篇文章主要介绍了VB6 RecordSet与XML转换前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Public Function SaveRSToXML(ByVal ConnectionString As String,ByVal strsql As String) As String
    Dim oCn As New ADODB.Connection
    Dim oRs As New ADODB.Recordset
    Dim oStream As New ADODB.Stream
    
    oCn.Open ConnectionString
    oRs.Open strsql,oCn,adOpenKeyset,adLockReadOnly
    oRs.Save oStream,adPersistXML
    SaveRSToXML = oStream.ReadText
    
    oStream.Close
    Set oStream = Nothing
    
    oRs.Close
    Set oRs = Nothing
    
    oCn.Close
    Set oCn = Nothing
End Function

Public Function RecordsetFromXMLString(ByVal sXml As String) As ADODB.Recordset
    Dim oStream As ADODB.Stream
    Set oStream = New ADODB.Stream
    
    oStream.Open
    oStream.WriteText sXml

    oStream.Position = 0

    Dim oRecordset As ADODB.Recordset
    Set oRecordset = New ADODB.Recordset
       
    oRecordset.Open oStream

    oStream.Close
    Set oStream = Nothing

    Set RecordsetFromXMLString = oRecordset

    Set oRecordset = Nothing
End Function
原文链接:https://www.f2er.com/vb/258640.html

猜你在找的VB相关文章