Share via


Returning to the First Row of the Rowset

IRowset::RestartPosition moves the next fetch position used by GetNextRows to the first row of the rowset. The source code for IRowset::RestartPosition follows.

// CImpIRowset::ResartPosition ---------------------------------------
//
// @mfunc Repositions the next fetch position to the start of the rowset
//
// - all rows must be released before calling this method
// - it is not expensive to Restart us, because we are from a single table
//
//
// @rdesc   Returns one of the following values:
//      @flag S_OK                  | Method Succeeded
//      @flag DB_E_ROWSNOTRELEASED  | All HROWs must be released before calling
//
STDMETHODIMP CImpIRowset::RestartPosition
    (
    HCHAPTER    hChapter        //@parm IN | The Chapter handle.
    )
{    
   // make sure all rows have been released
   // Fail even if CANHOLDROWS is true
    if( ((m_pObj->m_prowbitsIBuffer)->ArrayEmpty() != S_OK) )
        return ResultFromScode( DB_E_ROWSNOTRELEASED );

    // set "next fetch" position to the start of the rowset
   m_pObj->m_irowFilePos = 0;

    // clear "end of cursor" flag
    m_pObj->m_dwStatus &= ~STAT_ENDOFCURSOR;

    return ResultFromScode( S_OK );
}

See Also

Tasks

Writing an OLE DB Provider: An Introduction