代码是:
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) 不能写入!!!
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) 不能写入!!!
修改用sql的update