Moving Data to the Desktop

When you send data from the handheld to the desktop you have to read through the records of the remote database and translate them into appropriate structures on the desktop. Here is the step-by-step process, starting with the choices you have in how you read through the records.

Finding the Number of Records

SyncGetDBRecordCount finds the number of records in a database:

long SyncGetDBRecordCount(BYTE fHandle, WORD &rNumRecs);

Call it with:

WORD numRecords;
err = SyncGetDBRecordCount(rHandle, numRecords);

Reading Records

You can read records in a remote database using any of the following strategies:

  • Iterate through each record, locating the next altered record.

  • Look up exact records via unique record ID.

  • Read the nth record in the database.

We employ the last strategy for reading the records from our Sales order databases and the first strategy when we fully synchronize our customer list. There are a few points worth mentioning about each strategy.

Iterating through each record, stopping only for altered ones

If you want to iterate through the records and stop only on the ones that have been modified, use SyncReadNextModifiedRec. It retrieves a record from the remote database if the dirty bit in the record has been set.

A variation of this routine is SyncReadNextModifiedRecInCategory, which also filters based on the record’s category. This function takes the category index as an additional parameter.

Looking up exact records via unique record ID

Sometimes you ...

Get Palm OS Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.