Ok I've written a test app. The test app connects to the database, when I run via visual cron it does not.
Note the commented out connection string (the one you suggested) when I try this I can't connect to the database either via debugging or through visual cron.
Here's the code .. note I've blanked the password out!
// ODBCDriverTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "ODBCDriverTest.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#pragma comment(lib, "odbc32.lib")
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
SQLPOINTER rgbValue;
int i = 5;
rgbValue = &i;
SQLCHAR OutConnStr[512];
SQLSMALLINT OutConnStrLen;
HWND desktopHandle = GetDesktopWindow(); // desktop's window handle
// Allocate environment handle
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
// Set the ODBC version environment attribute
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0);
// Allocate connection handle
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
// Set login timeout to 5 seconds
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER)(rgbValue), 0);
const char *con_string = "DRIVER={Oracle dans ORACLE_10g};UID=xxxxxxx;PWD=xxxxxxx;DBQ=xxxxxxx;GDE=T";
// const char *con_string = "Provider=Oracle;Database type= Oracle;UID=xxxxxx;PWD=xxxxxxx;DBQ=xxxxxx;GDE=T";
retcode = SQLDriverConnect( // SQL_NULL_HDBC
hdbc,
desktopHandle,
(SQLCHAR*)con_string,
strlen(con_string),
OutConnStr,
512,
&OutConnStrLen,
(SQLUSMALLINT)SQL_DRIVER_COMPLETE_REQUIRED );
// Allocate statement handle
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
MessageBox(desktopHandle,"Success!","ODBC Driver loaded!",MB_OK);
// Process data
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
SQLDisconnect(hdbc);
}
else
{
MessageBox(GetDesktopWindow(),"Failed!","ODBC Driver connect",MB_OK);
}
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
}
}
SQLFreeHandle(SQL_HANDLE_ENV, henv);
}
return nRetCode;
}