CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 1999
    Location
    CA, USA
    Posts
    47

    Disconnected Recordsets in ADO

    Hi,
    I am developing MTS components in VC++. The component methods return recordsets. For that I am opening a connection to database and then opening the recordset against the connection object i created. Once the recordset has been opened, I would like to close the connection object and set the connection pointer to null before returning from the methods. Basically I want to return a disconnected recorset. But VC++ doesn't allow me close the connection object. I have to keep the connection object till my client uses the recordset. Incase of VB I am able to close the connection object and return the recordset. Why this is not possible in VC++.

    Can anyone throw light on creating Disconnected recordsets in VC++, their uses ( advantages).??

    Thanks & regards

    Kishore


  2. #2
    Join Date
    Apr 1999
    Posts
    27

    Re: Disconnected Recordsets in ADO

    Take a look at the atricle ADO is AOK Part 2 (here at codeguru). the sample code shows you how.

    Bob


  3. #3
    Join Date
    Aug 1999
    Location
    CA, USA
    Posts
    47

    Re: Disconnected Recordsets in ADO

    Hi
    Thanks for the reply.. The reason why i posted this question is " I am able to close the connection object successfully and return the recordset( disconnected) from a method without doing any extra in VB" . But in case of VC++, i need to call "put-activerefconnection and do the remaining to return a disconnected recordset"? Why is that? How VB is able to do that??

    I hope you got point?

    Thanks & Regards
    Kishore


  4. #4
    Join Date
    Apr 1999
    Posts
    27

    Re: Disconnected Recordsets in ADO

    I am not sure of the VB code needed to create a disconnected recordset, but below is what I use in a method to create and send back a disconnected recordset (actually, the IDsiapatch of the recordset). So while I can not answer why you have to set the activeconnection in VC and not in VB.

    YOu may want to take a look at the article here called (something like) "creating disconnected recordsets in VC++" It is in the Database/ADO section I think. It started me on my trip. Though, the sample in that article returns a Recordset object, where I have modified it to return the IDispatch of the recordset. Take a look at that and this code below.

    It may be that VB takes care of alot of this for you. (My VB skills are slimm at best).


    _variant_t vHolder;
    m_Recordset.CreateInstance(__uuidof(Recordset));
    //Client side cursor is required for disconnected recordsets
    m_Recordset->CursorLocation = adUseClient;
    m_Recordset2->Open( SQL,m_Connection2.GetInterfacePtr(),adOpenKeyset, adLockOptimistic, -1);

    // Disconnect the recordset
    m_Recordset2->PutRefActiveConnection(NULL);

    vHolder = static_cast<IDispatch*>(m_Recordset2);
    *Result = vHolder.Detach();



  5. #5
    Join Date
    Aug 1999
    Location
    CA, USA
    Posts
    47

    Re: Disconnected Recordsets in ADO

    Hi
    Thanks for the reply. I also got the same doubt.. Whatever it is ( VB or VC++), I am using IDispatch in all the cases, Then, How come i am able to pass disconnected recordset in VB in normalway and i am unable to do that in VC++.

    If you are able to get that answer, pl mail me. Here i am trying various combinatins to find out, if i got the answer, i will post that.

    Thanks once again
    Kishore
    [email protected]


  6. #6
    Guest

    Re: Disconnected Recordsets in ADO

    Hello All(&Bob),

    I am relatively new to both COM and ADO and have a question relating to Bob Place's method of implementing a disconnected recordset in VC.

    Does anyone know what code is required for the Client to access this disconnected recordset.

    Thanks in Advance.

    Grant Taylor.

    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured