Seems like this should be needed. Perhaps calling this ( and SQLFreeStmt(cursor->hstmt, SQL_UNBIND);) would alleviate the need to call SQLFreeStmt(cursor->hstmt, SQL_CLOSE); twice?

Just guessing here. The docs aren't too helpful: http://msdn.microsoft.com/en-us/library/windows/desktop/ms709284(v=vs.85).aspx