My application written in C++ using ADO (via COM) fails all of a
sudden. Here is a snippet of where it fails:
------------ START SNIPPET ------------
CoInitialize(NULL);
LOG(LOG_MESSAGE, "Adding command to database\n");
_RecordsetPtr pResultSet(__uuidof(Recordset));
_CommandPtr command = NULL;
HRESULT hr = myConnection.CreateInstance(_uuidof(Connection));
if (FAILED( hr )){
LOG(LOG_ERROR, "Can't create an instance of ADO.Connection\n");
} // end if
else {
// open the Database.
try {
string strDsn = "DSN=mydsn";
string strUserName = "myusername";
string strPassword = "mypassword";
SAFE_CALL( myConnection->Open( strDsn.c_str(), strUserName.c_str(),
strPassword.c_str(), 0 ) );
}
catch (_com_error &e){
LOG(LOG_ERROR, "Description = %s\n", (char*) e.Description());
}// end catch (_com_error &e)
catch(...){
LOG(LOG_ERROR, "Unhandled Exception\n");
}// end catch (...)
------------ END SNIPPET ------------
The first catch block is activated - _com_error - but the output is as follows:
Description = (null)
What does this mean, and what's the fix? I've looked for websites with
more information but found nothing. I'm inclined to think this has
something to do with the machine it's running on. This very same code
runs fine with
throwing errors on a test machine that is setup up in the same manner
as the host. |