MDAC 2.5 SDK - ADO


 

ConvertToString Method Example (VB)

See Also

Public Sub ConvertToStringX()
    Dim oRDF As RDSServer.DataFactory
    Dim oRDC As RDS.DataControl
    Dim oRs As ADODB.Recordset
    Dim vString As Variant
    Dim sConnString As String
    Dim sSQL As String

    ' Create a DataFactory object
    Set oRDF = New RDSServer.DataFactory

    ' Get all of the Author records
    sConnString = "Provider=sqloledb;" & _
                        "Data Source=(local);" & _
                        "Initial Catalog=pubs;" & _
                        "Network Library=DBMSSOCN;" & _
                        "Trusted_Connection=Yes;"
    sSQL = "Select * From authors"
    Set oRs = oRDF.Query(sConnString, sSQL)
    Debug.Print oRs.RecordCount

    ' Convert the recordset into a MIME formatted string
    vString = oRDF.ConvertToString(oRs)

    ' Convert string value back into an ADO Recordset
    Set oRDC = New RDS.DataControl
    oRDC.SQL = vString
    oRDC.ExecuteOptions = adcExecSync
    oRDC.FetchOptions = adcFetchUpFront
    oRDC.Refresh
    Debug.Print oRDC.Recordset.RecordCount
End Sub