Set connection point cause Recordset MoveFirst error 
Author Message
 Set connection point cause Recordset MoveFirst error

Hi:
I have encounterred a strange problem, I created a
recordset first, then create a sink object and find the
connection point of the recordset, advise it.

After I successfully open the recordset, the MoveFirst
cause error"IDispatch 3150," Operation cancelled.

If I ran unadvise after advise, everything is fine.
I download the CRstEvent from Microsoft sample code, one
thing I have doubt is the CRstEvent inherited from
RecordsetEventVt(regular interface), while _Recordset's
connection point is an Dispatch Interface.

I am confused, what's going on?

Thanks
Pat

===============================================
   _RecordsetPtr m_RecordsetPtr(__uuidof(Recordset));

        m_TableID = tableID;
        if (tableID < VIEW_START)  
          m_Table.Append(_tableNames[tableID]);
        else
      m_Table.Append(_viewNames[tableID-VIEW_START]);

        ppRstGenericEvent = new CRstEvent();

        hr = m_RecordsetPtr->QueryInterface(__uuidof
(IConnectionPointContainer),
                (void **)&pCPC);
        if (FAILED(hr)) return hr;

        hr = pCPC->FindConnectionPoint(__uuidof
(RecordsetEvents), &pCP);
                pCPC->Release();
        if (FAILED(hr)) return hr;

        hr = ppRstGenericEvent->QueryInterface(__uuidof
(IUnknown), (void **) &pUnk);
            if (FAILED(hr)) return hr;
        ppRstGenericEvent->AddRef();

        DWORD   dwRstEvt;      
    hr = pCP->Advise(pUnk, &dwRstEvt);
                //pCP->Unadvise(dwRstEvt);

    pCP->Release();
        if (FAILED(hr)) { //MessageBox(0, "failed
connect", "DD", MB_OK);
                return hr;}

        try {

        _ConnectionPtr sp_con = NULL;

        sp_con=CConnectionFactory::getActiveConnection();

    CComBSTR query(L"SELECT * from ");
        query.Append(m_Table.m_str);
        hr = m_RecordsetPtr->Open(_variant_t(query),
_variant_t((IDispatch *) sp_con, true),
                        adOpenKeyset, adLockOptimistic,
adCmdText);
        //m_RecordsetPtr->PutRefActiveConnection(NULL);

        m_RecordsetPtr->MoveFirst();



Mon, 28 Mar 2005 06:43:47 GMT  
 Set connection point cause Recordset MoveFirst error
May it be that you handle WillMove event and set the status to
adStatusCancel?
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hi:
> I have encounterred a strange problem, I created a
> recordset first, then create a sink object and find the
> connection point of the recordset, advise it.

> After I successfully open the recordset, the MoveFirst
> cause error"IDispatch 3150," Operation cancelled.

> If I ran unadvise after advise, everything is fine.
> I download the CRstEvent from Microsoft sample code, one
> thing I have doubt is the CRstEvent inherited from
> RecordsetEventVt(regular interface), while _Recordset's
> connection point is an Dispatch Interface.



Mon, 28 Mar 2005 07:03:28 GMT  
 Set connection point cause Recordset MoveFirst error
Igor:
you are the man, you are right. Thanks
Pat

Quote:
>-----Original Message-----
>May it be that you handle WillMove event and set the
status to
>adStatusCancel?
>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken



>> Hi:
>> I have encounterred a strange problem, I created a
>> recordset first, then create a sink object and find the
>> connection point of the recordset, advise it.

>> After I successfully open the recordset, the MoveFirst
>> cause error"IDispatch 3150," Operation cancelled.

>> If I ran unadvise after advise, everything is fine.
>> I download the CRstEvent from Microsoft sample code, one
>> thing I have doubt is the CRstEvent inherited from
>> RecordsetEventVt(regular interface), while _Recordset's
>> connection point is an Dispatch Interface.

>.



Mon, 28 Mar 2005 07:15:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Connection Points causing memory leaks

2. BUG: Multiple threads Cause Connection Busy Error in the Driver

3. HELP - (Some) Printer Drivers causing FALSE floating point errors - (how to fix/mask)

4. value of ESP not properly saved ERROR using connection points

5. adding support for connection points and errors

6. MFC Connection Point client app compilation errors...

7. MFC Connection Point client app compilation errors...

8. Connection Points and connection lost – what to do?

9. Setting mdiParent causes error on this.close()

10. CTime Member of Recordset... Causes access violation

11. Closing a RecordSet after change causes COM exception

12. Read multiple recordset with one connection

 

 
Powered by phpBB® Forum Software