Marshalling ADO Recordset


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Marshalling ADO Recordset

  1. #1
    David McCarter Guest

    Marshalling ADO Recordset


    I am having trouble sending an ADO Recordset to a VB COM EXE using ByVal (see
    code below). I can't send the Recordset unless I close it. Once I close it,
    I can't open it on the other end. What gives?

    David

    Set rsData = New ADODB.Recordset
    rsData.Fields.Append "booComplementaryFlag", adVariant
    rsData.Fields.Append "booContinuityFlag", adVariant
    rsData.Fields.Append "booLocked", adVariant
    rsData.Fields.Append "dtmOrderDate", adVariant
    rsData.Fields.Append "intCustomerID", adVarinat
    rsData.Fields.Append "strOrderKey", adVariant
    rsData.Fields.Append "Package", adVariant
    rsData.CursorLocation = adUseClient
    rsData.ActiveConnection = Nothing
    rsData.StayInSync = False
    rsData.open


    I then add some data, call .update and call .close


  2. #2
    Paul Clement Guest

    Re: Marshalling ADO Recordset

    On 13 Jul 2000 12:51:14 -0700, "David McCarter" <davidm@vbtt.com> wrote:


    I am having trouble sending an ADO Recordset to a VB COM EXE using ByVal (see
    code below). I can't send the Recordset unless I close it. Once I close it,
    I can't open it on the other end. What gives?

    David

    Set rsData = New ADODB.Recordset
    rsData.Fields.Append "booComplementaryFlag", adVariant
    rsData.Fields.Append "booContinuityFlag", adVariant
    rsData.Fields.Append "booLocked", adVariant
    rsData.Fields.Append "dtmOrderDate", adVariant
    rsData.Fields.Append "intCustomerID", adVarinat
    rsData.Fields.Append "strOrderKey", adVariant
    rsData.Fields.Append "Package", adVariant
    rsData.CursorLocation = adUseClient
    rsData.ActiveConnection = Nothing
    rsData.StayInSync = False
    rsData.open

    I think the statement to disconnect the Recordset is incorrect. Try:

    Set rsData.ActiveConnection = Nothing


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  3. #3
    David McCarter Guest

    Re: Marshalling ADO Recordset


    >I think the statement to disconnect the Recordset is incorrect. Try:
    >
    >Set rsData.ActiveConnection = Nothing


    Nope, that does not fix it. When I send the Recordset to the VB COM EXE,
    I get the error:

    Requested Conversation Not Supported

    David


  4. #4
    Ted McNeal Guest

    Re: Marshalling ADO Recordset


    "David McCarter" <davidm@vbtt.com> wrote:
    >
    >>I think the statement to disconnect the Recordset is incorrect. Try:
    >>
    >>Set rsData.ActiveConnection = Nothing

    >
    >Nope, that does not fix it. When I send the Recordset to the VB COM EXE,
    >I get the error:
    >
    >Requested Conversation Not Supported
    >
    >David
    >


    Dave,

    I think the problem revolves around confusion of the close method for an
    ADO recordset. When you close a recordset the class remains but the fields
    collection (metadata on fields and the actual data) itself is closed. If
    you have an active connection closing then openning will essential requery
    the record source. If you create a recordset on the fly then close it you
    will not be able to retrieve it because it did not originate from a data
    source. Normally, as I am sure you know, you connect to a data source get
    your data then set the active connection to nothing then pass your recordset.
    If the active connection is nothing, even if it orginated from say SQL Server,
    you cannot close the recordset then open it again because there is no connection
    to repopulate the fields collection in the recordset.

    I think I see that your issue is passing the recordset object across processes.
    An ADO recordset is suppose to cross process boundaries without issue.
    I would try to pass it without closing it. You may want to try creating
    a clone to pass.

    Yet, an alternative that will work in your case will require ADO 2.5. You
    can create your recordset, open it, populate it, persist it in xml into a
    stream object, then call readtext from the stream object to get a string
    that contains the raw xml. The string will cross the process boundaries
    without issue. On the com exe side you can load the xml string back into
    a new stream object then open a recordset based on the newly created stream
    object.

    Also, a couple of other notes. You can not define the cursor type after
    you have created fields. This doesn't matter because the default is adClientBatch.
    The resync command is not related to your job,it is used for heirarchial
    recordsets. You do not need to set the activeconnection property for a adhoc
    recordset to nothing because it is inherently disconnected.

    Best of luck,

    Ted McNeal


  5. #5
    David McCarter Guest

    Re: Marshalling ADO Recordset


    Thanks for your help. You gave me some good ideas.

    I can't pass the recordset without closing it. I get the error in the previous
    post. Strange huh?

    David


    >I think I see that your issue is passing the recordset object across processes.
    > An ADO recordset is suppose to cross process boundaries without issue.


    >I would try to pass it without closing it. You may want to try creating
    >a clone to pass.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center