首页 新闻 会员 周边

VC 中数据库不能插入数据

0
悬赏园豆:20 [已关闭问题] 关闭于 2012-06-24 10:59

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;


}
提示 基础类已停止工作

另外 数据库已连接成功

C++
dyhui1992的主页 dyhui1992 | 初学一级 | 园豆:4
提问于:2012-06-23 16:50
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册