reading a recordset back from a persisted stream 
Author Message
 reading a recordset back from a persisted stream

reading a recordset back from a persisted stream

I am confused as to how to grab and open a
recordset ( disconnected ) - once I persist it to a stream. (FSO)
I have found persisting as XML to a stream and then opening that stream to
retrive the XML works -

But to create a new recordset to read the stream back in ?? HOW ??
the syntax might be like:

Dim rs as new adodb.recordset
rs.open theStream, [ but what connection object ?? ]

I tried to create on to the stream, but that also failed.
So... what's the secret ??

Thanks



Wed, 19 Mar 2003 03:00:00 GMT
 reading a recordset back from a persisted stream

Hi, Andrew:

According to  Professional ADO 2.5 Programming
by David Sussman, James M. Conard, Brian Matsik et. al.
ISBN:   1-861002-75-0, page 266:

rsSales.Save streamobject, adPersistXML ' save to stream
rsSales.Save streamobject, , , , adCmdFile ' create rs from stream

Make sure rsSales.CursorLocation = adUseClient or adUseClientBatch

Doesn't the above work?

Regards,
-Toby

Quote:

>reading a recordset back from a persisted stream

>I am confused as to how to grab and open a
>recordset ( disconnected ) - once I persist it to a stream. (FSO)
>I have found persisting as XML to a stream and then opening that stream to
>retrive the XML works -

>But to create a new recordset to read the stream back in ?? HOW ??
>the syntax might be like:

>Dim rs as new adodb.recordset
>rs.open theStream, [ but what connection object ?? ]

>I tried to create on to the stream, but that also failed.
>So... what's the secret ??

>Thanks



Thu, 20 Mar 2003 03:00:00 GMT
 reading a recordset back from a persisted stream

I have not explained the problem well enough -

         Set GetADORecordsetFromTable = rstSQL
         rstSQL.Save F, adPersistADTG ' regular binary format
         Dim ObjRS As New ADODB.Recordset
         Debug.print  rstSQL.CursorLocation '  ( this is adUseClient - # 3 )

          ' now the recordset is disconnected, saved to a stream that I can
pass around
          ' but how do I read it back into an ADO recordset
          ' the open property asks for a connection object
          ' but if I use that what is the format to establish it ?
          '

         Dim streamCnx As New ADODB.Connection
         Set streamCnx = Me.JetconnStream(F, errormes)
         ObjRS.Open F, streamCnx, adOpenForwardOnly
         'Set ObjRS = f   ' ??? try

          This did not seem to work either :

Function JetconnStream(F As Stream, errormes As String) As ADODB.Connection
Dim ADOJetProvider As String
On Error GoTo errorTrap
Dim bdidError As Boolean
   Set JetconnStream = New ADODB.Connection
        With JetconnStream
        .Provider = Me.thisJetProvider
        .Properties("Jet OLEDB:Database Password") = Me.thisMDBPassword '
"xxxx"
        .ConnectionString = F
        .CursorLocation = adUseClient
        .Open F
        End With
Exit Function
errorTrap:
errormes = Err.Description
' OK so try nothing
'    Jetconn.Properties("Jet OLEDB:Database Password") = ""
'    Jetconn.Open strMDBpath
End Function



Quote:
> Hi, Andrew:

> According to  Professional ADO 2.5 Programming
> by David Sussman, James M. Conard, Brian Matsik et. al.
> ISBN:   1-861002-75-0, page 266:

> rsSales.Save streamobject, adPersistXML ' save to stream
> rsSales.Save streamobject, , , , adCmdFile ' create rs from stream

> Make sure rsSales.CursorLocation = adUseClient or adUseClientBatch

> Doesn't the above work?

> Regards,
> -Toby


> >reading a recordset back from a persisted stream

> >I am confused as to how to grab and open a
> >recordset ( disconnected ) - once I persist it to a stream. (FSO)
> >I have found persisting as XML to a stream and then opening that stream
to
> >retrive the XML works -

> >But to create a new recordset to read the stream back in ?? HOW ??
> >the syntax might be like:

> >Dim rs as new adodb.recordset
> >rs.open theStream, [ but what connection object ?? ]

> >I tried to create on to the stream, but that also failed.
> >So... what's the secret ??

> >Thanks



Thu, 20 Mar 2003 03:00:00 GMT
 reading a recordset back from a persisted stream
Hi, Andrew:

The following snippet from the ADO Help file (Recordset.Open method):

"If you pass a Stream object in the Source argument, you should not pass information into
the other arguments. Doing so will generate an error. The ActiveConnection information is
not retained when a Recordset is opened from a Stream.
The default for the Options argument is adCmdFile if no connection is associated with the
Recordset. This will typically be the case for persistently stored Recordset objects."

In a simple test I ran, I created a form with a DataGrid and 1 Command button and put the
following code in the form. Although this code works as expected, I *did* notice that if I
persist the recordset as

         "adoRS.Save F, adPersistADTG"

then it did *not* work!!

'/////////////////////////////////////
' Beginning of form
'/////////////////////////////////////
Private F As ADODB.Stream
Private adoRS As ADODB.Recordset
'__________________________________________________________________
Private Sub Command1_Click()
Set adoRS = New ADODB.Recordset
adoRS.Open F, , , , adCmdFile
Set DataGrid1.DataSource = adoRS
Set adoRS = Nothing
End Sub
'__________________________________________________________________
Private Sub Form_Load()
Set adoRS = New ADODB.Recordset
Set F = New ADODB.Stream
Command1.Caption = "Stream->RS"
Dim cSQL As String
Dim ConnStr As String
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=c:\nwind.mdb"

cSQL = "SELECT * FROM Customers"

Call OpenDisconnectedRS(adoRS, cSQL, ConnStr)

adoRS.Save F, adPersistXML
Set adoRS = Nothing

End Sub
'__________________________________________________________________
Public Sub OpenDisconnectedRS(oRs As ADODB.Recordset, cSQL As String, ConnStr As String)
On Error GoTo abhauen
  oRs.CursorLocation = adUseClientBatch
  oRs.LockType = adLockBatchOptimistic
  oRs.CursorType = adOpenStatic

  oRs.Open cSQL, ConnStr, , , adCmdText
  oRs.MarshalOptions = adMarshalModifiedOnly
  oRs.ActiveConnection = Nothing
  If Not oRs.EOF And Not oRs.BOF Then
   oRs.MoveLast
   oRs.MoveFirst
   Exit Sub
  End If

abhauen:
If Err.Number = -2147467259 Then
 MsgBox "The server is down. Try again later" & vbCrLf & Err.Description, vbCritical +
vbInformation
 End
End If

End Sub

'/////////////////////////////////////
' End of form
'/////////////////////////////////////

Wonder what we're missing to be able to restore a adPersistADTG stream???

Regards,
-Toby

Quote:
>         Set GetADORecordsetFromTable = rstSQL
>         rstSQL.Save F, adPersistADTG ' regular binary format
>         Dim ObjRS As New ADODB.Recordset
>         Debug.print  rstSQL.CursorLocation '  ( this is adUseClient - # 3 )

>          ' now the recordset is disconnected, saved to a stream that I can
>pass around
>          ' but how do I read it back into an ADO recordset
>          ' the open property asks for a connection object
>          ' but if I use that what is the format to establish it ?



Fri, 21 Mar 2003 03:00:00 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. Opening a recordset from a Persisted XML Stream Object (ADO 2.5)

2. Persisting Recordsets to Response Stream

3. Error persisting XML stream to ADO recordset

4. write stream back to recordset

5. Losing Record when persisting to Stream

6. Persisting an ADO2.5 Stream object to a Session-variable

7. Losing Record when persisting to Stream

8. query a persisted recordset

9. Encrypt persisted recordset?

10. Urgent: Shaping Persisted Recordset - Repost

11. Bug in ADO 2.7 with persisted ADTG recordset?

12. Persisting RecordSet missing first record if bound


 
Powered by phpBB® Forum Software