Hi YujianYao-MSFT,
I think it is not like a compatibility issue. Today I tried to add my own SQLGetFunctions. The SQLExecDirect and SQLExecute could work successfully if I enabled them in SQL_API_ODBC3_ALL_FUNCTIONS block. However if I just enable them, SQLGetInfo will not be found. So I enabled SQLGetInfo, then SQLAllocHandle for statement is not found. So I enabled SQLAllocHandle. But the SQLExecDirect/SQLExecute problem came again. Just like I did not set all of them. I am not sure how Microsoft ODBC driver manager is implemented, seems there is some connection between these 3 functions. Maybe Microsoft DM is checking some info based on SQLGetInfo to decide if the ODBC driver could support SQLExecute/SQLExecDirect?
--my ODBC driver code of SQLGetFunctions
SQLRETURN SQLGetFunctions(SQLHDBC conn, SQLUSMALLINT funcId,
SQLUSMALLINT* supported) {
if (funcId == SQL_API_ODBC3_ALL_FUNCTIONS) {
supported[SQL_API_SQLEXECUTE>>4] |= (1 << ((SQL_API_SQLEXECUTE) & 0x000F));
supported[SQL_API_SQLEXECDIRECT >> 4] |= (1 << ((SQL_API_SQLEXECDIRECT) & 0x000F));
supported[SQL_API_SQLGETINFO>>4] |= (1 << ((SQL_API_SQLGETINFO) & 0x000F));
supported[SQL_API_SQLGETDATA >> 4] |= (1 << ((SQL_API_SQLGETDATA)&0x000F));
supported[SQL_API_SQLALLOCHANDLE>>4] |= (1 << ((SQL_API_SQLALLOCHANDLE) & 0x000F));
supported[SQL_API_SQLALLOCSTMT>>4] |= (1 << ((SQL_API_SQLALLOCSTMT) & 0x000F));
supported[SQL_API_SQLFREEHANDLE >> 4] |=
(1 << ((SQL_API_SQLFREEHANDLE)&0x000F));
supported[SQL_API_SQLFREESTMT >> 4] |=
(1 << ((SQL_API_SQLFREESTMT)&0x000F));
supported[SQL_API_SQLCONNECT >> 4] |= (1 << ((SQL_API_SQLCONNECT)&0x000F));
supported[SQL_API_SQLDRIVERS >> 4] |= (1 << ((SQL_API_SQLDRIVERS)&0x000F));
supported[SQL_API_SQLDRIVERCONNECT >> 4] |=
(1 << ((SQL_API_SQLDRIVERCONNECT)&0x000F));
supported[SQL_API_SQLDISCONNECT >> 4] |=
(1 << ((SQL_API_SQLDISCONNECT)&0x000F));
} else if (funcId == SQL_API_ALL_FUNCTIONS) {
supported[SQL_API_SQLEXECDIRECT] = 1;
supported[SQL_API_SQLEXECUTE] = 1;
supported[SQL_API_SQLGETINFO] = 1;
supported[SQL_API_SQLALLOCSTMT] = 1;
} else if (funcId == SQL_API_SQLEXECDIRECT ||
funcId == SQL_API_SQLEXECUTE || funcId == SQL_API_SQLGETINFO ||
funcId == SQL_API_SQLALLOCSTMT || funcId == SQL_API_SQLALLOCHANDLE) {
*supported = 1;
}
return SQL_SUCCESS;
}