how to convert a _variant_t to recordset in vc++?
-
Hello All, How to convert a variant, which is returned by vb dll that actually contains a adodb.recordset, to recordet in vc++? I casted it to IDispatch and to Recordset. But always I'm not getting records. If I used recordcount, it's returning only -1. Advance thanks for ur reply. regards, ramesh :confused: :confused:
-
Hello All, How to convert a variant, which is returned by vb dll that actually contains a adodb.recordset, to recordet in vc++? I casted it to IDispatch and to Recordset. But always I'm not getting records. If I used recordcount, it's returning only -1. Advance thanks for ur reply. regards, ramesh :confused: :confused:
You can convert the IDispatch to a _RecordsetPtr. //mycontrol.h _RecordsetPtr m_pRS; //mycontrol.cpp STDMETHODIMP CMeCTable::put_DataSource(IDispatch *newVal) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) if (m_pRS == NULL) m_pRS = NULL; HRESULT hr = newVal->QueryInterface(__uuidof(_RecordsetPtr), (void**)&m_pRS); if FAILED(hr) { return E_FAIL; } }
-
You can convert the IDispatch to a _RecordsetPtr. //mycontrol.h _RecordsetPtr m_pRS; //mycontrol.cpp STDMETHODIMP CMeCTable::put_DataSource(IDispatch *newVal) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) if (m_pRS == NULL) m_pRS = NULL; HRESULT hr = newVal->QueryInterface(__uuidof(_RecordsetPtr), (void**)&m_pRS); if FAILED(hr) { return E_FAIL; } }
Hi chenzhu, Thank you very much for your suggestion. Even after using the QueryInterface also I didn't get the exact value from the GetRecordCount function. I got one reply such that it is because of the cursor type. Now, I can traverse thru recordset by using Move functions. The only thing I couldn't able to get the records count and fields count. If any more solutions, let me know. Thanking you, regards, Ramesh :eek: :rolleyes: