代码是:
void CTestDlg::OnButton1() 
{
// TODO: Add your control notification handler code here
   CoInitialize(NULL);//初始化
    _ConnectionPtr pConn(__uuidof(Connection));//产生connection智能指针
    _RecordsetPtr pRst(__uuidof(Recordset));//产生recordset智能指针
try
{
    pConn->ConnectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=sdsdsdsdd";
   pConn->Open("","","",adConnectUnspecified);//打开数据库
char exstr[256];
int bno=1002;
   sprintf(exstr, "select * from test where no=%d", bno);
   pRst=pConn->Execute(exstr,NULL,adCmdText);
   pRst->PutCollect ("no", _variant_t((long)1001));
} catch(_com_error     &     e)     
{     
      MessageBox(e.ErrorMessage());     
}     
catch(...) 

    MessageBox( "unknown   exception! "); 

    pRst->Close();
   pConn->Close();
   pRst.Release();
   pConn.Release();

}
错误是ADODB.Recordset (0x800A0CB3)   不能写入!!!

解决方案 »

  1.   

    你这是查询,怎么修改呢?
    修改用sql的update
      

  2.   

      pRst->PutCollect ("no", _variant_t((long)1001));这一句不是就是修改记录集里面的no?
      

  3.   

    sprintf(exstr, "select * from test where no=%d", bno);吧select换成insert不行吗
      

  4.   

    _ConnectionPtr 通过Execute得到的记录集_RecordsetPtr 是静态的,好像只能顺序查询,如果想用记录集修改,最好通过_RecordsetPtr 来Open,然后PutCollect 
      

  5.   

    哎。。本来想叫你们帮我修改上面的代码的,结果一个人都没的,那我把分给flydreamGG和zyq5945了,他们讲得是对的,现在我自己解决了,谢谢!!