|
语句如下:
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
pConn->ConnectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MobileInfo";
pConn->Open("","","",adConnectUnspecified);
_variant_t RecordsAffected;
CString StrSQL=_T("insert into Place values('4564','654')");
try
{
pConn->Execute(_bstr_t(StrSQL),&RecordsAffected,adCmdText);
}
catch(_com_error e)
{
AfxMessageBox("语句或条件输入错误");
return;
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
运行出现了错误:
Runtime Error!
Program:...Visual Studio\MyProjects\MobileInfo\Debug\MobileInfo.exe
This application has requested the Runtime to terminate it in an unusual way.Please contact the application's support team for more information.
但是这一句
insert into Place values('4564','654')
在SQL查询分析器里面是可以正常执行的,我执行之后把'4564','654'这个记录删除了,再到vc里面这样执行,就不行了...
请问为什么呢??
而且这种错误仅仅限于插入和删除的时候,在查询的时候是不会有错的. |
|