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 );
}
}