I am trying to learn ODBC/CLI Programming so please bear with me if this appears silly, but I am not able to resolve an apparently simple issue. I have posted the relevant portions of the code below.
The problem is that the SQLExecute () fails with SQLSTATE=42601. The exact error message that I get is "0x00167250 "[IBM][CLI Driver][DB2/NT] SQL0007N The character " " following "ÌÌÌÌÌÌ©%|I0ý" is not valid. SQLSTATE=42601"
Can someone please help me point out issues / ways to debug this Issue on MS Visual Studio 2012 (Express). (DB2 Express C Version 10.1.2)
I have checked the manuals and the SQLSTATE refers to an invalid character in the Query String. As far as I understand, there isn't any! Nor am I able to figure it out from the Error message produced. Please help!
Regards,
/* Define a SELECT SQL Statement That uses a Paramter
Marker. !! Protect from Buffer Overflow !! */
strcpy((char *) sqlQuery, "SELECT EMPNO, LASTNAME FROM ");
strcat((char *) sqlQuery, "EMPLOYEE WHERE JOB = ?");
/*Prepare the SQL Statement */
sqlReturnCode = SQLPrepare(*StmtHandle,
(SQLCHAR*) sqlQuery,
SQL_NTS);
if (sqlReturnCode != SQL_SUCCESS){
//Free Connection Handle
//Free Environment Handle
GetCLIErrorInfo(SQL_HANDLE_STMT, *StmtHandle);
return -60;
}
sqlReturnCode = SQLBindParameter(*StmtHandle,
1,
SQL_PARAM_INPUT,
SQL_C_CHAR,
SQL_CHAR,
sizeof(jobType),
0,
jobType,
sizeof(jobType),
NULL);
if (sqlReturnCode != SQL_SUCCESS){
GetCLIErrorInfo(SQL_HANDLE_STMT, *StmtHandle);
return -70;
}
/*Populate the Bound Application Variable*/
strcpy((char*) jobType, "DESIGNER");
/*Execute the SQL Statement*/
sqlReturnCode = SQLExecute(*StmtHandle);
if (sqlReturnCode != SQL_SUCCESS){
//Free Connection Handle
//Free Environment Handle
GetCLIErrorInfo(SQL_HANDLE_STMT, *StmtHandle);
return -80;
}