This project has moved. For the latest updates, please go here.

Keep retrieving the same record (sequential search)

Jan 24, 2013 at 7:31 PM
Edited Jan 24, 2013 at 7:33 PM

I am using the following code to retrieve all records from an ESE database.  The "TryMoveNext" executes the right number of times  but when I use ColumnRetrieve, I get the same record values over and over.  It seem that the cursor is positioned on the same record.  Any ideas?  Do I need to do a Seek to get positioned on the correct record?  Code looks kind of like this:

using (var instance = new Instance("DBname"))
{
    instance.Parameters.CircularLog = true;
    instance.Init();
    using (var session = new Session(instance))
    {
        // Attach the database ...
        using (var table = new Table(session, dbid, TableName, OpenTableGrbit.None))
        {
                Api.JetSetTableSequential(session, table, SetTableSequentialGrbit.None);

                Api.MoveBeforeFirst(session, table);
                while (Api.TryMoveNext(session, table))
                {
                      //
                      // Retrieve all columns by their types and such
                      //
                     tmpInt = Api.RetrieveColumnAsInt32(session, tableID, columnid);
                .....
                }
            }
        }
    }
}

 

Jan 24, 2013 at 7:36 PM

In the example code you are retrieving tmpInfo from tableID, not from the table variable that you are calling TryMoveNext on. Is it possible that you code has the same problem?

Jan 24, 2013 at 7:43 PM

OMG, I am going to scream.  A whole day wasted.  You are so correct.  I used a sample from one of the discussions and they used TableID.  The correct move is what you suggested.

That was the difference.  Thank you so much for your reply.
 using (var table = new Table(session, dbid, TableName, OpenTableGrbit.None))
        {
                Api.JetSetTableSequential(session, table, SetTableSequentialGrbit.None);

                Api.MoveBeforeFirst(session, table);
                while (Api.TryMoveNext(session, table))
                {
                      //
                      // Retrieve all columns by their types and such
                      //
                     tmpInt = Api.RetrieveColumnAsInt32(session, table, columnid);
                .....
                }
            }
        }

 

Jan 24, 2013 at 8:02 PM

You could consider using my esentserialize framework.

It has basic stuff like cursor navigation already implemented.

Take a look at this source file for sample code:

http://esentserialize.codeplex.com/SourceControl/changeset/view/a03b66824099#DemoApp/Program.cs