|
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 ("Incorrect statement or condition input");
return;
}
pRst-> Close ();
pConn-> Close ();
pRst.Release ();
pConn.Release ();
CoUninitialize ();
I got an error when running:
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 the SQL query analyzer.After I executed, I deleted the records of '4564' and '654', and then executed it in vc, but it didn't work ...
Excuse me, why?
And this kind of error is only limited to the time of insertion and deletion, and there will be no mistake when querying. |
|