Google Answers Logo
View Question
 
Q: C++ ADO Connection throwing Error ( No Answer,   0 Comments )
Question  
Subject: C++ ADO Connection throwing Error
Category: Computers > Programming
Asked by: nocturnal_code-ga
List Price: $20.00
Posted: 26 Jan 2006 08:13 PST
Expires: 29 Jan 2006 15:12 PST
Question ID: 437895
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.

Clarification of Question by nocturnal_code-ga on 26 Jan 2006 08:14 PST
The last sentence should read:

This very same code runs fine WITHOUT throwing errors on a test
machine that is setup up in the same manner as the host.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy