Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Problem in passing recordset from server to client

Problem in passing recordset from server to client

Scheduled Pinned Locked Moved COM
helpquestioncomsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ramjan
    wrote on last edited by
    #1

    Hello, I have some sort of problem in COM while passing the ADO recordset object through variant to the client. In the server I can able to traverse through the recordset:-O . Once I got the variant at the client end, the variant contains the NULL (VT_EMPTY):confused: . What is the problem? For your clarity I'm putting some excerption from my coding. At Server_End HRESULT CServer::Function1(VARIANT *pvarRSObj, VARIANT *pvarRetVal) { _RecordsetPtr pRSObj = NULL; try { pRSObj->CreateInstance(__uuidof(Recordset)); pRSObj->Open(varQueryString, (IDispatch*)m_conObj, adOpenKeyset, adLockBatchOptimistic, adCmdText); pvarRSObj->vt = VT_DISPATCH; pvarRSObj->pdispVal = (IDispatch*)pRSObj; } catch(_com_error &e) { ERRBOX(e.ErrorMessage()); return e.Error(); } catch(...) { ERRBOX("Unknown Exception"); return E_FAIL; } return S_OK; } At Client_End InvokeServer() { IServer *pServer; //instantiation of server pServer->Function1(&varRSObj, &varResponse); CHECKVARIANTTYPE(&varRSObj); //It'll check the variant type // this is showing me that variant contains VT_EMPTY. if(varRSObj.vt == VT_DISPATCH) { //necessary action } } Timely reply appreciated. Regards, Ramesh

    S 1 Reply Last reply
    0
    • R ramjan

      Hello, I have some sort of problem in COM while passing the ADO recordset object through variant to the client. In the server I can able to traverse through the recordset:-O . Once I got the variant at the client end, the variant contains the NULL (VT_EMPTY):confused: . What is the problem? For your clarity I'm putting some excerption from my coding. At Server_End HRESULT CServer::Function1(VARIANT *pvarRSObj, VARIANT *pvarRetVal) { _RecordsetPtr pRSObj = NULL; try { pRSObj->CreateInstance(__uuidof(Recordset)); pRSObj->Open(varQueryString, (IDispatch*)m_conObj, adOpenKeyset, adLockBatchOptimistic, adCmdText); pvarRSObj->vt = VT_DISPATCH; pvarRSObj->pdispVal = (IDispatch*)pRSObj; } catch(_com_error &e) { ERRBOX(e.ErrorMessage()); return e.Error(); } catch(...) { ERRBOX("Unknown Exception"); return E_FAIL; } return S_OK; } At Client_End InvokeServer() { IServer *pServer; //instantiation of server pServer->Function1(&varRSObj, &varResponse); CHECKVARIANTTYPE(&varRSObj); //It'll check the variant type // this is showing me that variant contains VT_EMPTY. if(varRSObj.vt == VT_DISPATCH) { //necessary action } } Timely reply appreciated. Regards, Ramesh

      S Offline
      S Offline
      Shadi Al Kahwaji
      wrote on last edited by
      #2

      Hi, You can return a Recordset as an IDispatch pointer like this: STDMETHODIMP CMyClass::GetAllRecords(BSTR bstrSearchKey, IDispatch **output) { .... .... *output = (IDispatch*) pRecordset.Detach(); //Return recordset as IDispatch } Regards, ShadiK Shadi Al-Kahwaji

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups