Re: CBulkRowset and MovePrev()

Erik Valdes <[email protected]> Mon, 22 Jul 2002 14:09:26 -0700
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
I recall running into something like this a few months ago when I was
researching what kind of rowset I needed to implement. I believe you are
correct although I haven't verified it.  There is also a problem with the
MovePrev() in the CRowset class.  What I ended up doing was subclassing and
overwriting the MovePrev() method.  You may have to do the same.  Here's my
MovePrev() for CRowset():

class CMyRowset : public CRowset
{
public:

        // Move to the previous record
        HRESULT MovePrev()
        {
      HRESULT hr;

      // This method can fail if the next fetch position is row 1.
      hr = MoveNext(-2, true);

      if (hr == DB_E_BADSTARTPOSITION)
      {
         // If we started on row 1, this will put us at
         // end of rowset, which is a better "error"
         hr = MoveNext(-1,true);
      }
                return hr;
        }
}

-----Original Message-----
From: Rudolf Wiener [mailto:[email protected]]
Sent: Monday, July 22, 2002 1:29 PM
To: [email protected]
Subject: [OLEDB_DEV] CBulkRowset and MovePrev()


Hi,

I have a CBulkRowset, opened with DBPROP_CANFETCHBACKWARDS set to true. The
following sequence of statements does not work:

    cmd.MoveLast();
    cmd.MovePrev();
    cmd.MovePrev();

The second of the MovePrev() returns DB_S_ENDOFROWSET while there are still
thousands of records in the database. I stepped through the implementation
of the ATL consumer template and -- while I'm not sure I completely
understand everything that's happening -- I have the impression that there
might be a problem in the implementation. To me it looks like MoveLast()
moves to the last record and reads this one record into the cache. The first
MovePrev() issues a MoveNext(-2,true) which in the implementation moves 2
recs to the beginning of the table and tries to read 10 records into the
cache. At this moment the return code is DB_S_ENDOFROWSET (of course, we're
positioned at the second last record) which is handeled correctly because
the implementation realizes it is working with a cache. The second
MovePrev() however checks for a non-S_OK too early and returns the saved
return code DB_S_ENDOFROWSET.

Am I misinterpreting things here or am I missing to set specific properties
or what?

TIA
Rudi

You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.