The program of ATL COM can run succeed. But at last it shows that the executive file of this COM is runtime error and abnormal programer
termination. Then I notice that the parameter of the function shows errors CXX0030 and CXX0017. Why? The code is the following:
HRESULT hr = S_OK;
long id = 123;
//initial a BSTR varialbe
wchar_t * sss = L"abc";
_ConnectionPtr pObjADO_Connection = NULL;
// Create ADO connection
hr = pObjADO_Connection.CreateInstance(__uuidof(Connection));
hr = pObjADO_Connection->Open(
// String I/O stream to write SQL statement
// Write the SQL statement into a string
// Cast variant dates to bstr_t so they will be converted into a string
strSQLStatement << L"INSERT INTO Customers (CustomerID, Password) VALUES ("
<< id << L",' "
<< pwd << L"')" << ends;
bstr_t strSQLStmt = strSQLStatement.str().c_str();
// Execute the SQL statement to add a record
hr = pObjADO_Connection->Execute(strSQLStmt, &vntRecordsAffected,
Besides,I want to know how I can convert a variable of the BSTR data type to a
variable of the _bstr_t data type,vice
versa. I look up the mothed in the msdn,but it doesn't work. Can you help me? Thanks.
_bstr_t tstr(str.operaotr const char*())
I'm very sorry. In ATL, it doesn't support the type CString. My ATL COM can run. But there is still many bugs.