情况是这样的.
ADO操作SQL数据库 用查询语句的时候,一切正常,但是将查询语句改成了添加或者更新语句,编译无错误,一运行,点击按钮报错abnormal program termination!
虽然报错,但是进入数据库查看数据,发现SQL 添加\更新语句仍然执行成功.
所以很不理解这是什么原因造成的.   网上说是什么野指针..我是菜鸟完全不懂啊, 请各位朋友帮忙看看 谢谢代码如下(按钮中的)
查询时
____________________________________________
void CAdoDlg::OnBtnQuery() 
{
// TODO: Add your control notification handler code here
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
_CommandPtr pCmd(__uuidof(Command)); //pConn->ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=pubs";
pConn->ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=pubs;Data Source=DK";
pConn->Open("","","",adConnectUnspecified); pRst=pConn->Execute("select id from zh where pwd='fdf'",NULL,adCmdText);
while(!pRst->rsEOF)
{
((CListBox*)GetDlgItem(IDC_LIST1))->AddString(
(_bstr_t)pRst->GetCollect("id"));
pRst->MoveNext();
}

pRst->Close();
pConn->Close();
pCmd.Release();
pRst.Release();
pConn.Release();
CoUninitialize();
}
______________________________________________________
插入\更新时
________________________________________________________
void CAdoDlg::OnBtnQuery() 
{
// TODO: Add your control notification handler code here
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
_CommandPtr pCmd(__uuidof(Command)); //pConn->ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=pubs";
pConn->ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=pubs;Data Source=DK";
pConn->Open("","","",adConnectUnspecified);
   try{
pRst=pConn->Execute("UPDATE kkk SET pwd = '500' WHERE idd = 'as'",NULL,adCmdText);
   }
   catch   (CException*   e)   {   
  char   buf[2048];   
  e->GetErrorMessage(buf,   2048);   
  e->Delete();   
  ::AfxMessageBox(buf);   
  }   

pRst->Close();
pConn->Close();
pCmd.Release();
pRst.Release();
pConn.Release();
CoUninitialize();
}