Use SQLFreeStmt(SQL_CLOSE) rather than SQLCloseCursor(). Leverage existing state where possible rather than additional state.