急vc+ado+sql 只读不能写入啊该如何处理
急~~~vc+ado+sql 只读不能写入啊
代码是:
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) 不能写入!!!
------解决方案--------------------
_ConnectionPtr 通过Execute得到的记录集_RecordsetPtr 是静态的,好像只能顺序查询,如果想用记录集修改,最好通过_RecordsetPtr 来Open,然后PutCollect
------解决方案--------------------
看这个例子
代码是:
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) 不能写入!!!
------解决方案--------------------
_ConnectionPtr 通过Execute得到的记录集_RecordsetPtr 是静态的,好像只能顺序查询,如果想用记录集修改,最好通过_RecordsetPtr 来Open,然后PutCollect
------解决方案--------------------
看这个例子