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. ATL / WTL / STL
  4. OLEDB (CCommand) Problem

OLEDB (CCommand) Problem

Scheduled Pinned Locked Moved ATL / WTL / STL
databasehelpsysadminalgorithmsperformance
2 Posts 2 Posters 16 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’m facing some problem when I want to send the ICommand interface to the Client to work around the data fetched from the Database by OLEDB provider. I can successfully query the database and traverse through the Rowset at the Server end. When I’m packing the ICommand interface in a variant (as dispatch), at the Client End it throws the Error “No such interface supported”). Here is the excerpt from my code HRESULT CDAC::GetCommand (BSTR bstrQuery, VARIANT *pvarColumnInfo, VARIANT *pvarCmd) { HRESULT hr; CSession session; CCommand objCmd; LONG lRetVal; try { USES_CONVERSION; // Getting the Database connection by using the connection string lRetVal = GetDBConnection(); // Creating the session for the transaction hr = session.Open(m_objDBSrc); CHECK_HR(hr); // Create the Command by using the session for the query hr = objCmd.Create(objSession, bstrQuery); CHECK_HR(hr); // Command Optimization hr = objCmd.Prepare(); CHECK_HR(hr); // Execute the Command hr = objCmd.Open(); CHECK_HR(hr); // Place the column Information in the OUT VARIANT pvarColumnInfo->vt = VT_BYREF; pvarColumnInfo ->byref = (PVOID)cmdObj.m_pColumnInfo; // Place the command object in the OUT VARIANT pvarCmd->vt = VT_DISPATCH; pvarCmd->pdispVal = (IDispatch*)cmdObj.m_spCommand.Detach(); // Unable to get the ICommand, return the error if(pvarCmd ->pdispVal == NULL) { hr = E_FAIL; goto CLEANUP; } } catch(_com_error &ce) { ERRBOX(ce.ErrorMessage(), "Error"); hr = ce.Error(); goto CLEANUP; } catch(...) { ERRBOX("Unknown Error", "Error"); hr = E_UNEXPECTED; goto CLEANUP; } // Successfully Completed. Return Success code. hr = S_OK; CLEANUP: return hr; } Can anyone suggest that where I’m failing or how to pass the Command information from the Server to Client? Advance thanks, Regards, Ramesh M.

    S 1 Reply Last reply
    0
    • R ramjan

      Hello, I’m facing some problem when I want to send the ICommand interface to the Client to work around the data fetched from the Database by OLEDB provider. I can successfully query the database and traverse through the Rowset at the Server end. When I’m packing the ICommand interface in a variant (as dispatch), at the Client End it throws the Error “No such interface supported”). Here is the excerpt from my code HRESULT CDAC::GetCommand (BSTR bstrQuery, VARIANT *pvarColumnInfo, VARIANT *pvarCmd) { HRESULT hr; CSession session; CCommand objCmd; LONG lRetVal; try { USES_CONVERSION; // Getting the Database connection by using the connection string lRetVal = GetDBConnection(); // Creating the session for the transaction hr = session.Open(m_objDBSrc); CHECK_HR(hr); // Create the Command by using the session for the query hr = objCmd.Create(objSession, bstrQuery); CHECK_HR(hr); // Command Optimization hr = objCmd.Prepare(); CHECK_HR(hr); // Execute the Command hr = objCmd.Open(); CHECK_HR(hr); // Place the column Information in the OUT VARIANT pvarColumnInfo->vt = VT_BYREF; pvarColumnInfo ->byref = (PVOID)cmdObj.m_pColumnInfo; // Place the command object in the OUT VARIANT pvarCmd->vt = VT_DISPATCH; pvarCmd->pdispVal = (IDispatch*)cmdObj.m_spCommand.Detach(); // Unable to get the ICommand, return the error if(pvarCmd ->pdispVal == NULL) { hr = E_FAIL; goto CLEANUP; } } catch(_com_error &ce) { ERRBOX(ce.ErrorMessage(), "Error"); hr = ce.Error(); goto CLEANUP; } catch(...) { ERRBOX("Unknown Error", "Error"); hr = E_UNEXPECTED; goto CLEANUP; } // Successfully Completed. Return Success code. hr = S_OK; CLEANUP: return hr; } Can anyone suggest that where I’m failing or how to pass the Command information from the Server to Client? Advance thanks, Regards, Ramesh M.

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      Try using QueryInterface to get the IUnknown of the cmd interface, and pass that through in your variant as an IUnknown, then at the client end use QueryInterface to get the ICommand interface back. Steve S [This signature space available for rent]

      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