打开数据库出错:
我是用下面的函数进行打开数据库的,但是m_pRecordset 没有定义,这是怎么回事,应该怎样定义?
谢谢!
BOOL CTestDlg::OpenRecordSet(_RecordsetPtr &recPtr,CString &strSQL)
{
COMCApp*pApp=(COMCApp*)AfxGetApp();
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
recPtr->Open(strSQL.AllocSysString(),
pApp->m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch (_com_error e)
{
CString strError;
strError.Format("警告:打开数据表时发生异常。错误信息:%s",\
e.ErrorMessage());
AfxMessageBox(strError);
return FALSE;
}
return TRUE;
}
我是用下面的函数进行打开数据库的,但是m_pRecordset 没有定义,这是怎么回事,应该怎样定义?
谢谢!
BOOL CTestDlg::OpenRecordSet(_RecordsetPtr &recPtr,CString &strSQL)
{
COMCApp*pApp=(COMCApp*)AfxGetApp();
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
recPtr->Open(strSQL.AllocSysString(),
pApp->m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch (_com_error e)
{
CString strError;
strError.Format("警告:打开数据表时发生异常。错误信息:%s",\
e.ErrorMessage());
AfxMessageBox(strError);
return FALSE;
}
return TRUE;
}
能够运行但是出现错误:警告:打开数据表时发生异常。错误信息:无效指针
你可以借鉴一下
http://topic.csdn.net/u/20100429/11/a1a68cd2-d942-4f6b-b387-69a130ec5888.html?12046