|
The statement is as follows:
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("Statement or condition input error");
return;
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
An error occurred during operation:
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.
But this sentence
insert into Place values('4564','654')
It can be executed normally in SQL Query Analyzer. After I executed it, I deleted the records of '4564' and '654', and then executed it in vc, it would not work...
May I ask why?
And this kind of error is only limited to insert and delete, there will be no mistakes in query
By the way, after the error is prompted, go to the SQL to view the database. The data is successfully inserted, but an error message will appear when it is executed. |
|