***CODE FRAGMENT START***

        phist = GetOrCreateHistoryForPerson(1, &recordNum);

        DmWrite(phist, OffsetOf(PHist, NumEntrys), &num, sizeof(Word));

        g = MemPtrRecoverHandle(phist);
        MemHandleUnlock(g);

        MemHandleResize(g, OffsetOf(PHist, datetimeass) +
sizeof(DateTimeAssignment) * num);
        phist = (PHist *)MemHandleLock(g);
        DmWrite(phist, OffsetOf(PHist, datetimeass), dts, sizeof(dts));
        MemHandleUnlock(g);
        DmReleaseRecord(gPHistDB, recordNum, false);

**CODE FRAGMENT END**

and:

static PHist *GetOrCreateHistoryForPerson(SDWord ID, UInt* recordnumPtr)
{

        VoidHand        theHistoryHandle;
        PHist           *phist;
        Boolean     exists;
        UInt16       recnum;
        *recordnumPtr = PHistRecordNumber(ID, &exists);
        if (exists)
        {
                theHistoryHandle = DmGetRecord(gPHistDB, *recordnumPtr);
                ErrNonFatalDisplayIf(!theHistoryHandle, "DMGetRecord failed!");
                phist = (PHist *)MemHandleLock(theHistoryHandle);
        }
        else
        {
                PHist o;
                theHistoryHandle = DmNewRecord(gPHistDB, &recnum, sizeof(PHist));
                if (!theHistoryHandle)
                {
                        return NULL;
                }
                o.NumEntrys = 0;
                o.ID = ID;
                phist = (PHist *)MemHandleLock(theHistoryHandle);
                DmWrite(phist, 0, &o, sizeof(o));
        }
        return phist;
}

What this does is work fine.  The records are there, I can access them, they
aren't screwed up at all.  What happens is that when my application quits,
there is a Fatal Error.

Thanks for any help anyone has to offer.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Dave
Lippincott
Sent: Monday, July 09, 2001 1:19 PM
To: Palm Developer Forum
Subject: Re: Database malfunction


Sorry, the amazing Karnac is on vacation this week.  Could you post some
code for the rest of us?


-- 
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