Problem finding first record using CDaoRecordset class 
Author Message
 Problem finding first record using CDaoRecordset class

I checked the MSDN library and I could not find any suggestions about the
best way to open an MDB file and read the first record.

My method works fine the first time I call my function (after calling
myDaoRecordset.Open()).

However the next time I execute the code below I do not get the first
record.  By the first record I mean the first row in my MDB file.

  if(!myDaoRecordset.IsBOF())
    myDaoRecordset.MoveFirst();

Any ideas about what I am doing wrong here?

For example, do I need to use some combination of the following:
m_strSort = ???
myDaoRecordset.m_strFilter = ???
myDaoRecordset.Requery();

Or, do I need to use SetBookmark(), GetLastModifiedBookmark()?

My Recordset type is Dynaset.

TIA.

Michael T.



Sun, 11 Sep 2005 12:16:04 GMT  
 Problem finding first record using CDaoRecordset class
Michael,

what do you mean by "first record" or "first row" in the table??.  in general,
when you open a recordset, you will not get the records presented in ANY ordered
fashion unless you specify either the order by or a group by construct.  you may
get a resultset ordered by the value of an index if there is a join in the sql
statement - but such behavior would be database/provider specific at best.

When you open a table or a view in Access (the GUI on the Jet Database engine)
there may be sorting/ordering going on there (either implicit or explicit) - the
that the rows in the table or view are in some specific order and that order is
maintained by the database is a false assumprtion.  to get something close to
what you are looking for, add an identity/autonumber field to the underlying
table and then add an order by on that field in the select statement....

regards
roy fine


Quote:
> I checked the MSDN library and I could not find any suggestions about the
> best way to open an MDB file and read the first record.

> My method works fine the first time I call my function (after calling
> myDaoRecordset.Open()).

> However the next time I execute the code below I do not get the first
> record.  By the first record I mean the first row in my MDB file.

>   if(!myDaoRecordset.IsBOF())
>     myDaoRecordset.MoveFirst();

> Any ideas about what I am doing wrong here?

> For example, do I need to use some combination of the following:
> m_strSort = ???
> myDaoRecordset.m_strFilter = ???
> myDaoRecordset.Requery();

> Or, do I need to use SetBookmark(), GetLastModifiedBookmark()?

> My Recordset type is Dynaset.

> TIA.

> Michael T.



Sun, 11 Sep 2005 23:56:58 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem finding first record using CDaoRecordset

2. CDaoRecordset can't find record

3. CDaoRecordset can't find record

4. Problem with find a record using DAO

5. Reading records using MFC CDaoRecordSet (fast method required!)

6. Reading records using MFC CDaoRecordSet (fast method required!)

7. Problem in adding new records using CRecordset class (in dialogbox)

8. MEMORY LEAK using CDaoRecordset Class and AddNew() method

9. CDaoRecordSet class - using

10. Utility to find out modified record using Checksum algorithm

11. Finding records using CRecordset

12. Finding last record added using ODBC

 

 
Powered by phpBB® Forum Software