Hi all,
Im having an issue when executing SQLExecDirect function in the code below:
Code:SQLHANDLE handle; SQLHENV env; SQLHDBC dbc; SQLHSTMT stmt; SQLRETURN ret; SQLCHAR conn[256] = "DSN=MY_DSN;UID=user;PWD=pwd;"; //Allocate and environment handle SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); //ODBC 3 support SQLSetEnvAttr (env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); //Allocate a connection handle SQLAllocHandle (SQL_HANDLE_DBC, env, &dbc); //Connect to the DSN ret = SQLDriverConnect(dbc, NULL, conn, SQL_NTS, outstr, sizeof (outstr), &outstrlen, SQL_DRIVER_NOPROMPT); if (SQL_SUCCEEDED(ret)){ outfile1<<"SQLDriverConnect succeded"<<endl; //Allocate Statement handle ret = SQLAllocHandle (SQL_HANDLE_STMT, dbc, &stmt); if (SQL_SUCCEEDED(ret)){ outfile1<<"Statement handle allocated"<<endl; //Execute Query ret = SQLExecDirect(stmt, (unsigned char*)"SELECT * FROM SIEBUTV2.S_USER", SQL_NTS); if (SQL_SUCCEEDED(ret)){ outfile1<<"Execute query succeded"<<endl; outfile1.close(); return (SecurityErrOK); } else{ outfile1<<"Execute query failed"<<endl; outfile1.close(); return (SecurityErrNoSuchUser); } } else{ outfile1<<"Handle allocation failed"<<endl; outfile1.close(); return (SecurityErrNoSuchUser); } } else{ outfile1<<"SQLDriverConnect failed"<<endl; outfile1.close(); return (SecurityErrNoSuchUser); }
I have no issues in connecting to the dsn and allocating the sql statement as shown in the logged file:
SQLDriverConnect succeded
Statement handle allocated
But for some reason the execution stops at SQLExecDirect. No line is written in the dump file and ret value cannot be accessed. I am connecting to an Oracle DB from an application than runs in Windows 2008 R2. I dont really know how I can debug this further.
Any comments or tips would be highly appreciated.
Thanks in advance,


Reply With Quote
Bookmarks