void CExecDlg::OnBtnInsert()
{
// TODO: Add your control notification handler code here
UpdateData();
_RecordsetPtr pStuPtr;
pStuPtr.CreateInstance(__uuidof(Recordset));
HRESULT hr ;
try
{
hr = pStuPtr->Open("select * from [班级管理系统].[dbo].[s]",m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if(SUCCEEDED(hr))
{
pStuPtr->AddNew();
pStuPtr->PutCollect("sno",_variant_t(m_sno));
//pStuPtr->PutCollect("age",_variant_t(m_age));
pStuPtr->PutCollect("sname",_variant_t(m_name));
pStuPtr->PutCollect("dept",_variant_t(m_dept));
pStuPtr->PutCollect("comment",_variant_t(m_comment));
pStuPtr->Update();
}
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
return ;
}
pStuPtr->Close();
pStuPtr = NULL;
}
提示 基础类已停止工作
另外 数据库已连接成功