diff -c psqlodbc.orig\execute.c psqlodbc\execute.c *** psqlodbc.orig\execute.c Tue Dec 06 21:53:30 2005 --- psqlodbc\execute.c Wed Dec 14 01:18:40 2005 *************** *** 683,688 **** --- 711,717 ---- ConnectionClass *conn; RETCODE result; ConnInfo *ci; + STMT_Status old_status; #ifdef WIN32 HMODULE hmodule; *************** *** 719,724 **** --- 748,754 ---- * force method calls the driver manager's function on behalf of * the application. */ + old_status = stmt->status; #ifdef WIN32 if (ci->drivers.cancel_as_freestmt) *************** *** 733,739 **** result = PGAPI_FreeStmt(hstmt, SQL_CLOSE); #endif ! mylog("PGAPI_Cancel: PGAPI_FreeStmt returned %d\n", result); SC_clear_error(hstmt); return SQL_SUCCESS; --- 763,789 ---- result = PGAPI_FreeStmt(hstmt, SQL_CLOSE); #endif ! mylog("PGAPI_Cancel: PGAPI_FreeStmt(SQL_CLOSE) returned %d\n", result); ! ! #ifdef WIN32 ! /* ! * Brute force method calls SQLFreeStmt(SQL_RESET_PARAMS) as it seems ! * Microsoft Vistual FoxPro 9 needs it ! */ ! if (old_status != STMT_FINISHED) ! { ! if (ci->drivers.cancel_as_freestmt) ! { ! hmodule = GetModuleHandle("ODBC32"); ! addr = GetProcAddress(hmodule, "SQLFreeStmt"); ! result = addr((char *) (stmt->phstmt) - 96, SQL_RESET_PARAMS); ! } ! else ! result = PGAPI_FreeStmt(hstmt, SQL_RESET_PARAMS); ! ! mylog("PGAPI_Cancel: PGAPI_FreeStmt(SQL_RESET_PARAMS) returned %d\n", result); ! } ! #endif SC_clear_error(hstmt); return SQL_SUCCESS; *************** *** 741,750 **** /* In the middle of SQLParamData/SQLPutData, so cancel that. */ ! /* Free all previous data-at-exec buffers */ ! mylog("%s: Clearing parameters et al.\n", func); ! SC_free_params(stmt, STMT_FREE_PARAMS_ALL); stmt->data_at_exec = -1; stmt->current_exec_param = -1; stmt->put_data = FALSE; --- 791,812 ---- /* In the middle of SQLParamData/SQLPutData, so cancel that. */ ! #ifdef WIN32 ! /* ! * Brute force method calls SQLFreeStmt(SQL_RESET_PARAMS) as it seems ! * Microsoft Vistual FoxPro 9 needs it ! */ ! if (ci->drivers.cancel_as_freestmt) ! { ! hmodule = GetModuleHandle("ODBC32"); ! addr = GetProcAddress(hmodule, "SQLFreeStmt"); ! result = addr((char *) (stmt->phstmt) - 96, SQL_RESET_PARAMS); ! } ! else ! result = PGAPI_FreeStmt(hstmt, SQL_RESET_PARAMS); ! mylog("PGAPI_Cancel: PGAPI_FreeStmt(SQL_RESET_PARAMS) returned %d\n", result); ! #endif stmt->data_at_exec = -1; stmt->current_exec_param = -1; stmt->put_data = FALSE;