Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot connect to db in debug mode

Status
Not open for further replies.

littleRedRooster

Programmer
Oct 18, 2001
2
0
0
US
Hi, I am pretty new to C++ but I am supporting a huge C++ application. I am setting up a new environment on a Windows 2000 server (previously it was set up on an NT4 machine). For some reason when I run the application in debug mode I cannot connect to the oracle db, but when I execute my exe file (ctrl-F5) I am able to connect to the DB. I am using microsoft ODBC for Oracle drivers.

I am passing all the right parameters. I am pretty sure this is something environmental. I dont know if this has something to do with the way I have my project set up or has something to do with ODBC. Any help would greatly be appreciated. Thanks
 
Can you give a sample of the code you are using???

Tammy, Indiana
 
Well Here is some of the code, but this same code is running on the production box. Thats why I think it has to be something in my environment. But I am beating myself over the head trying to find out what it is.

phdbc = new HDBC;
if ( phdbc == NULL )
{
GENERATE_EXCEPTION (0,CDB_E_INSUFICIENT_MEMORY,
EXCEPTION_ERROR,NULL,NULL);
CLEANUP_ON_FALSE( FALSE );
}

rcSqlReturn = SQLAllocConnect( henv, phdbc );
if ( rcSqlReturn != SQL_SUCCESS )
{
strErrReturn = GetSQLErrorTexthenv,phdbc,NULL);

GENERATE_EXCEPTION (0,
CDB_E_ALLOCATE_CONNECTION,
EXCEPTION_ERROR,
strErrReturn.GetBuffer( strErrReturn.GetLength() ),NULL);

strErrReturn.ReleaseBuffer();

// SQLFreeConnect( *phdbc );
// call SqlError for more info.
delete phdbc;
phdbc = NULL;
CLEANUP_ON_FALSE( FALSE );
}

iUserLen = 0;
iPwdLen = 0;

strDatasetName = GetRegStrValue (LPSZRegKeyName, "DataSourceName", "dbConn");

lpSrc = strDatasetName.GetBuffer( strDatasetName.GetLength( ) );

if (lpSrc) iSrcLen = strlen (lpSrc);

strUserName = GetRegStrValue (LPSZRegKeyName, "DBUsername", "");

if (! strUserName.IsEmpty())
{
lpUser = strUserName.GetBuffer( strUserName.GetLength( ) );
if (lpUser) iUserLen = strlen (lpUser);
}

strUserPwd = GetRegStrValue (LPSZRegKeyName, "DBPassword", "");
if (! strUserPwd.IsEmpty())
{
lpPwd = strUserPwd.GetBuffer( strUserPwd.GetLength( ) );
if (lpPwd) iPwdLen = strlen (lpPwd);
}

APP_DEBUG ("Opening Datasource [%s]", lpSrc, NULL);


//THIS IS WHERE IT DOESN'T CONNECT AND ENTERS THE ERROR HANDLER

rcSqlReturn = SQLConnect( *phdbc, (unsigned char *)lpSrc, iSrcLen, (unsigned char *)lpUser, iUserLen, (unsigned char *)lpPwd, iPwdLen );



strDatasetName.ReleaseBuffer();

if ( rcSqlReturn != SQL_SUCCESS )
{
if ( rcSqlReturn != SQL_SUCCESS_WITH_INFO )
{
strErrReturn = GetSQLErrorText( NULL, *phdbc, NULL );

GENERATE_EXCEPTION (0,CDB_E_CONNECTION, EXCEPTION_ERROR,lpSrc, strErrReturn.GetBuffer( strErrReturn.GetLength() ) );
strErrReturn.ReleaseBuffer();
SQLFreeConnect( *phdbc );
delete phdbc;
phdbc = NULL;
// call SqlError for more info.
CLEANUP_ON_FALSE( FALSE );
}
}
 
The error checking is incomplete.
If the SQLConnect() return value _is_ SQL_SUCCESS_WITH_INFO you should get the SQL_STATE to see what went wrong.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top