OLEDB (CCommand) Problem
-
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.
-
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.