Hi all,

I am using CDK Java to build a conduit.  I wrote some codes to test the
behaviour of the SyncManager.  I am very confused as to how I can update
certain fields in an existing record.  I did something like the following:

===========================================================================
db = SyncManager.openDB("MYDBNAME", 0,
                        SyncManager.OPEN_READ |
                        SyncManager.OPEN_WRITE |
                        SyncManager.OPEN_EXCLUSIVE);
Log.AddEntry("DB opened", Log.NO_ERROR, true);
Log.AddEntry("DB has " + SyncManager.getDBRecordCount(db) + " record(s)",
             Log.NO_ERROR, false);
rec = new MyRecord(); // read 1st record
rec.setIndex(0);
try {
    SyncManager.readRecordByIndex(db, rec);
    Log.AddEntry("recID = " + rec.getId()
                 + "\n\t" + rec.getValue()
                 + "\n\t" + rec.getCode(),
                 Log.NO_ERROR, false);
} catch (java.io.IOException e) {
    System.err.println("IOException!  Cannot read record from DB");
}
try { // change 1st record
    rec.setCode(rec.getCode() + 1);
    SyncManager.writeRec(db, rec);
} catch (java.io.IOException e) {
    System.err.println("IOException!  Cannot write record to DB");
}
SyncManager.closeDB(db);
Log.AddEntry("DB closed", Log.NO_ERROR, true);
===========================================================================

Things seem to work properly when there is only one record in the database.
As soon as I add more codes to add more records in the database, the piece
of updating codes seems to break down.  It seems that the proper mapping of
the Record Indices and the Record IDs is messed up.  Please help...

Thanks,
Edmond


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to