//打开游标记录
BOOL CMemberView::ado_OpenCurRecordset(CString strTableName)
{
if(!m_fConnected) return FALSE;
if(strTableName.IsEmpty()) return FALSE;
AfxMessageBox("11");
//-------------------------------------------------------
HRESULT hr;
CString strQuery;
strQuery.Format("select * from %s", strTableName);
_bstr_t query = strQuery;
_bstr_t source = m_strSource;
AfxMessageBox("12");
try
{
hr = m_recordset->Open(query, source, adOpenDynamic, adLockOptimistic, adCmdText);
AfxMessageBox("13");
}
catch (_com_error &e)
{
MessageBox(e.ErrorMessage());
return FALSE;
}
//*/
AfxMessageBox("14");
return (SUCCEEDED(hr));
}运行到m_recordset->Open处出错,如下
IDispatch #error 3149
BOOL CMemberView::ado_OpenCurRecordset(CString strTableName)
{
if(!m_fConnected) return FALSE;
if(strTableName.IsEmpty()) return FALSE;
AfxMessageBox("11");
//-------------------------------------------------------
HRESULT hr;
CString strQuery;
strQuery.Format("select * from %s", strTableName);
_bstr_t query = strQuery;
_bstr_t source = m_strSource;
AfxMessageBox("12");
try
{
hr = m_recordset->Open(query, source, adOpenDynamic, adLockOptimistic, adCmdText);
AfxMessageBox("13");
}
catch (_com_error &e)
{
MessageBox(e.ErrorMessage());
return FALSE;
}
//*/
AfxMessageBox("14");
return (SUCCEEDED(hr));
}运行到m_recordset->Open处出错,如下
IDispatch #error 3149
CoInitialize(NULL);
{
m_bATLInited = TRUE;
#if _WIN32_WINNT >= 0x0400
HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
#else
HRESULT hRes = CoInitialize(NULL);
#endif
if (FAILED(hRes))
{
m_bATLInited = FALSE;
return FALSE;
}
return TRUE;
}void CMemberApp::ATLOut()
{
if (m_bATLInited)
{
CoUninitialize();
}
}
分别在Inistince
可以是"DSN=YourDSN"
或者是_variant_t((IDispatch*)m_pConn)其中m_pConn是_ConnectionPtr对象
unknown error 0x800aoe7d
你说的我也试过了,IDispatch #error是这个原因
但又出现了unknown error 0x800aoe7d的错误
source有问题,这个参数应该是和_ConnectionPtr对象有关系
例如:
_ConnectionPtr gl_pConnection;
....
....
m_pRs->Open(buf,gl_pConnection.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);