ODBC Fails on Server

I'd like to walk through your code for revision. I could possibly see something.

Could you post the source code?

If not, send it to my personnal address.

I'll take a look at it.
 
i 'll do it tomorrow morning (now at home), but i presume that is not a code's error as it's work on citrix without any trouble.
 
It's the code :
JDEBFRTN (ID) JDEBFWINAPI AllocateODBCHandle (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5704211 lpDS)
{
/************************************************************************
* Variable declarations
************************************************************************/
SQLHENV EnvironmentHandle;
SQLHSTMT StatementHandle;
SQLHDBC ConnectionHandle;
SQLRETURN retcode;
SQLINTEGER NativeErrorPtr = 0;
SQLSMALLINT TextLengthPtr;
SQLCHAR SQLState[5];
SQLCHAR* MessageText;
SQLSMALLINT BufferLength;
HUSER hUser = (HUSER)NULL;
ID ReturnValue = ER_SUCCESS;
ID idJDEDBReturnCode = JDEDB_PASSED;
char ServerName[30];
char UserName[15];
char Authentication[25];
int iCounter;
char StatementText[65535];
time_t BeginTime,CurrentTime;
double WaitingTime;
/************************************************************************
* Declare structures
************************************************************************/
DSDE5501Z1 dsDE5501Z1;
/************************************************************************
* Declare pointers
************************************************************************/

/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD5704211) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, "4363", (LPVOID) NULL);
return ER_ERROR;
}
/***************************************/
/* Initialisation of the Behavior zone */
/***************************************/
idJDEDBReturnCode = JDB_InitBhvr ( lpBhvrCom, &hUser, (char *) NULL, JDEDB_COMMIT_AUTO );

if ( idJDEDBReturnCode == JDEDB_FAILED )
{
strncpy(lpDS->szErrorMessage,(const char *)"078S",sizeof(lpDS->szErrorMessage));
if (lpDS->cSuppressErrorMessage != '1')
{
jdeSetGBRError ( lpBhvrCom, lpVoid, (ID) 0, "078S" ) ;
}
idJDEDBReturnCode = ER_ERROR;
ReturnValue = ER_ERROR;
}

/************************************************************************
* Set pointers
************************************************************************/

/************************************************************************
* Main Processing
************************************************************************/
/* Clear out the variables */

memset(ServerName,'\0',sizeof(ServerName));
memset(UserName,'\0',sizeof(UserName));
memset(Authentication,'\0',sizeof(Authentication));
// memset(StatementText,'\0',sizeof(StatementText));

lpDS->cErrorCode='0';
WaitingTime=(60*lpDS->nSenderTimeOut);
strcpy((char *)ServerName,(const char *)lpDS->szODBCDataSource);
strcpy((char *)Authentication,(const char *)lpDS->szUserPassword);
strcpy((char *)UserName,(const char *)lpDS->szUserName);
jdeStripTrailingBlanks(ServerName);


/* Now for the ODBC Code. . . .
Get a SQL Environment Handle. . . */
retcode =SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &EnvironmentHandle);
if (retcode!=SQL_SUCCESS)
{
strcpy(lpDS->szErrorMessage,"139E");
lpDS->cErrorCode='1';
jdeSetGBRError (lpBhvrCom, lpVoid, (ID) 0, "139E");
ReturnValue = ER_ERROR;
}
else
{
/* Specify the ODBC Environment Attributes. . . */
retcode =SQLSetEnvAttr(EnvironmentHandle,SQL_ATTR_ODBC_VERSION,(SQLPOINTER *)SQL_OV_ODBC3 ,0);
if (retcode!=SQL_SUCCESS)
{
strcpy(lpDS->szErrorMessage,"086Q");
lpDS->cErrorCode='1';
ReturnValue = ER_ERROR;
}
else
{
/* Get a Connection Handle. . . */
retcode =SQLAllocHandle(SQL_HANDLE_DBC, EnvironmentHandle, &ConnectionHandle);
if (retcode!=SQL_SUCCESS)
{
strcpy(lpDS->szErrorMessage,"129S");
lpDS->cErrorCode='1';
jdeSetGBRError (lpBhvrCom, lpVoid, (ID) 0, "129S");
ReturnValue = ER_ERROR;
}
else
{
/* Make the Connection. . . .! */
retcode =SQLConnect((SQLHDBC) ConnectionHandle,
(SQLCHAR *) ServerName,
(SQLSMALLINT) strlen(ServerName),
(SQLCHAR *) UserName,
(SQLSMALLINT) strlen(UserName),
(SQLCHAR *) Authentication,
(SQLSMALLINT) strlen(Authentication));
if (retcode!=SQL_SUCCESS)
{
strcpy(lpDS->szErrorMessage,"073T");
lpDS->cErrorCode='1';
jdeSetGBRError (lpBhvrCom, lpVoid, (ID) 0, "073T");
ReturnValue = ER_ERROR;
}
else
{
retcode =SQLAllocHandle(SQL_HANDLE_STMT, ConnectionHandle, &StatementHandle);
if (retcode!=SQL_SUCCESS)
{
strcpy(lpDS->szErrorMessage,"138H");
lpDS->cErrorCode='1';
jdeSetGBRError (lpBhvrCom, lpVoid, (ID) 0, "138H");
ReturnValue = ER_ERROR;
}
else
{
retcode=SQL_ERROR;
time(&BeginTime);
while (retcode!=SQL_SUCCESS)
{
memset(StatementText,(int)('\0'),sizeof(StatementText));
strcpy(StatementText,"LOCK TABLE F47011 IN EXCLUSIVE MODE");
retcode =SQLExecDirect(StatementHandle,
(SQLCHAR *) StatementText,
(SQLINTEGER) strlen(StatementText));
if (retcode!=SQL_SUCCESS)
{
strcpy(lpDS->szErrorMessage,"2257");
lpDS->cErrorCode='1';
MessageText=(SQLCHAR *)jdeAlloc(COMMON_POOL, 127, MEM_ZEROINIT);
BufferLength=127;
SQLGetDiagRec(SQL_HANDLE_STMT,StatementHandle,1,SQLState,&NativeErrorPtr,MessageText,BufferLength,&TextLengthPtr);
memset(&dsDE5501Z1,(int)('\0'),sizeof(DSDE5501Z1));
strcpy(dsDE5501Z1.szStatusCode,(const char *)SQLState);
strcpy(dsDE5501Z1.szODBCDescription,(const char *)MessageText);
ReturnValue = ER_ERROR;
jdeFree(MessageText);
/* break waiting loop if error is not egal to file in use */
if (NativeErrorPtr!=-913)
{
jdeSetGBRErrorSubText(lpBhvrCom,lpVoid,(ID)0,"5529",&dsDE5501Z1);
break;
}
else
{
time(&CurrentTime);
if (difftime(CurrentTime,BeginTime)<WaitingTime)
{
strcpy(lpDS->szErrorMessage," ");
lpDS->cErrorCode='0';
}
else
{
jdeSetGBRErrorSubText(lpBhvrCom,lpVoid,(ID)0,"5529",&dsDE5501Z1);
ReturnValue = ER_ERROR;
break;
}
}
}
}
lpDS->idStatementHandle = jdeStoreDataPtr(hUser, StatementHandle);
lpDS->idConnectionHandle = jdeStoreDataPtr(hUser, ConnectionHandle);
lpDS->idEnvironmentHandle = jdeStoreDataPtr(hUser, EnvironmentHandle);
}
}
}
}
}

/************************************************************************
* Function Clean Up
************************************************************************/

return (ReturnValue);
}

and then the compilation directive on the production server :
BSFN BUILD]
BuildArea=K:\Application\JDEdwardsONEWORLD\ddp\B7333\packages
DebugFlags=/Gz /Od /Zi /MDd /Yd /W4 /GX /Gy /D "_DEBUG"
OptimizationFlags=/Gz /O2 /MD /W4 /GX /Gy
OSReleaseLevel=5.0
DefineFlags=/D "WIN32" /D "_WINDOWS" /D "IAMASERVER" /D "KERNEL"
CompilerFlags=/nologo /c
LinkFlags=/DLL /DEBUG /SUBSYSTEM:windows /FORCE:MULTIPLE /FORCE:UNRESOLVED /INCREMENTAL:YES /VERBOSE /MAP
LinkLibraries=jdekrnl.lib jdel.lib jdenet.lib jdeipc.lib owver.lib
SimultaneousBuilds=8
InliningFlags=

[JDE_CG]
;TARGET=DEBUG
TARGET=RELEASE
INCLUDES=C:\Program Files\Microsoft Visual Studio\Vc98\include;C:\Program Files\Microsoft Visual Studio\Vc98\mfc\include;$(SYSTEM)\INCLUDE;$(SYSTEM)\INCLUDEV;$(SYSTEM)\CG;$(APP)\INCLUDE;
LIBS=C:\Program Files\Microsoft Visual Studio\Vc98\lib;C:\Program Files\Microsoft Visual Studio\Vc98\mfc\lib;$(SYSTEM)\LIB32;$(SYSTEM)\LIBV32;$(APP)\LIB32;
MAKEDIR=C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin
STDLIBDIR=C:\Program Files\Microsoft Visual Studio\Vc98\lib;C:\Program Files\Microsoft Visual Studio\Vc98\mfc\lib


On dep and local JDE.INI
[JDE_CG]
STDLIBDIR=C:\Program Files\Microsoft Visual Studio\VC98\lib
TPLNAME=EXEFORM2
ERRNAME=CGERR
TARGET=OPTIMIZE
INCLUDES=C:\Program Files\Microsoft Visual Studio\VC98\include;$(SYSTEM)\include;$(SYSTEM)\cg;$(APP)\include;$(SYSTEM)\includev
LIBS=C:\Program Files\Microsoft Visual Studio\VC98\lib;$(SYSTEM)\lib32;$(APP)\lib32;$(SYSTEM)\libv32
MAKEDIR=C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin
USER=JDE
 
Thanks for all the response
Working with some of yours recommendation, i finnaly indentify the trouble :
The precompiler option /GZ blok all pragma option and prevent us to set the correct byte alignement into the souce code.
Suppress this instruction into the jde.ini and insert correct pragla instruction into source code will do the programm to functionn. However, we have to revalidate all the function into our's production environnment and it's so heavy.
So just use the client functionnality.
 
Back
Top