Thanks for that. I did not see any info on WHICH creator ID to use
in the documentation. I inserted the generic 'STRT' for the sake of
example, but I did not have 'psys' in my actual code. I switched my
code to use 'psys' and that seems to work on my TX that I use for
testing.

I still haven't quite figured out the DmGetRecord DmReleaseRecord
thing yet. I thought I was on the right track because it was
working in Simulator 5.4. Yesterday I tried it on my TX and it was
a crash fest. Here is the code in the original daVinci API:
extern Err GetRecord(DmOpenRef db, UInt16 recordNum, void *item)
{
    void *src;
    void *recordH;
                              //Get the record from the database
    recordH = DmQueryRecord(db, recordNum);
    src = MemHandleLock(recordH);
    if (src == NULL) return dmErrIndexOutOfRange;
                              //Unpack the record
    UnpackRecord(db, item, src);
    MemHandleUnlock(recordH);
    return 0;
}

I changed it to:
extern Err GetRecord(DmOpenRef db, UInt16 recordNum, void *item)
{
    void *src;
    void *recordH;
    UInt32 value = 0;
    Err error = errNone;
    
    UInt8 highest;
    UInt32 count;
    UInt32 busy;
    
    //these lines were added
    error = FtrGet('psys',sysFtrNumDmAutoBackup, &value);
    if (error == 0)
    {
        error = DmSyncDatabase(db);
        if (error != errNone)
            ErrAlert(error);
    }
    else if (error == ftrErrNoSuchFeature)
        gBigBadError = error;
                              //Get the record from the database
    //recordH = DmQueryRecord(db, recordNum);// - this line was replaced by the 
following
    recordH = DmGetRecord(db, recordNum);
    src = MemHandleLock(recordH);
    if (src == NULL) return dmErrIndexOutOfRange;
                              //Unpack the record
    UnpackRecord(db, item, src);
    MemHandleUnlock(recordH);
    
    DmGetDatabaseLockState (db, &highest, &count, &busy);
    if (busy > 0)
    {
        DmReleaseRecord(db, recordNum, true);
        error = DmSyncDatabase(db);
    }
    return 0;
}

I noticed that calling DmReleaseRecord when a record is not busy causes the TX 
to crash (reset) hence the DmGetDatabaseLockState call. Am I on the right 
track? Why does MemHandleUnlock seem to clear the busy count?
-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to