Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Get A Recordset back from a Recordset persisted to a stream


Message #1 by andrew.c.watts@b... on Fri, 29 Sep 2000 20:07:47 +0100
I'd be inclined to use an ADO 2.5/2.6 Stream object instead, but if you want
to use a TextStream, you can do it like this:

Dim objConn As ADODB.Connection
Dim objRS As ADODB.Recordset
Dim objFSO As Scripting.FileSystemObject
Dim objTStream As Scripting.TextStream

Set objConn = New ADODB.Connection
objConn.Open "Provider=SQLOLEDB;Data Source=JULIANS1;Initial
Catalog=pubs;User ID=sa;Password="

Set objRS = objConn.Execute("SELECT * FROM authors")
objRS.Save "C:\authors.xml", adPersistXML
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTStream = objFSO.OpenTextFile("C:\authors.xml", ForReading)

' ... When you want to re-open the recordset:

Set objConn = New ADODB.Connection
objConn.Open "Provider=SQLOLEDB;Data Source=JULIANS1;Initial
Catalog=pubs;User ID=sa;Password="

Set objRS = New ADODB.Recordset
objRS.Open "C:\authors.xml"

Set objRS.ActiveConnection = objConn

Cheers,
Julian

Julian Skinner
Technical Architect
Wrox Press
http://www.wrox.com
julians@w...


-----Original Message-----
From: andrew.c.watts@b... [mailto:andrew.c.watts@b...]
Sent: 29 September 2000 20:08
To: professional vb
Subject: [pro_vb] Get A Recordset back from a Recordset persisted to a
stream


I can save an ADO recordset to a stream, convert to a string
and pass to some other process.

But how do I recover a recordset that has been saved to a stream ?

I can pass the stream back, but what ADO commands do I use 
to load it into a recordset ? ( DIsconnected )

something like ?

function GetStreamedRS(F as stream)
Dim rS as new ADODB.recordset
   set rs = f. whatever ???????????
End function

Thanks

  Return to Index