This error occurs when your code is binding with Data-At-Execution.
The function sequence error must be in SQLFetch or the next API after SQLExecute.
SQL_NEED_DATA is returned when a parameter is bound with a StrLenOrInd value of SQL_LEN_DATA_AT_EXEC(x) or SQL_DATA_AT_EXEC.
If you are not explicitly setting this in the SQLBindParameter call, then it is likely an uninitialized variable that is occasionally being set to these values.
If you don't want to stream input parameters, the best way to deal with it is to fix StrLen_or_IndPtr to the appropriate value for the type.
If you do want to send Data at exec, you need to call SQLParamData after SQLExecute. It will return the value you passed in for "ParameterValuePtr" below.
You can then use this to key into the stream to send with SQLPutData. You use SQLPutData to push the data up in chunks until you are done, then call SQLParamData again to get the next parameter to fill or to finish streaming.
The final SQLParamData will return the return code that would originally have been returned by SQLExecute.
SQLRETURN SQLBindParameter(
SQLHSTMT StatementHandle,
SQLUSMALLINT ParameterNumber,
SQLSMALLINT InputOutputType,
SQLSMALLINT ValueType,
SQLSMALLINT ParameterType,
SQLULEN ColumnSize,
SQLSMALLINT DecimalDigits,
SQLPOINTER ParameterValuePtr,
SQLLEN BufferLength,
SQLLEN * StrLen_or_IndPtr); <--- this is the value that is causing SQL_NEED_DATA to be returned