-----Original Message-----
From: Tong Chi Ho <[EMAIL PROTECTED]>
To: Palm Developers Forum List <[EMAIL PROTECTED]>
Cc: Palm Developers Forum List <[EMAIL PROTECTED]>
Date: Mi�rcoles 17 de Marzo de 1999 16:22
Subject: Save DB problem


>
>Dear all,
>
> I want to save some data in the DB, however i use the codes from
>the tutorial of CW5, I found that it will save the data in a new record of
>DB. Can anyone tell me that how can i save in the same record (overwrite
>the exist record)?
>
>Thank You
>Gary
>
>Here is the code of Save Function:
>
>static void EditSaveData(FieldPtr fld)
>{
> CharPtr text;
> VoidPtr textPtr;
> VoidHand textHandle;
> UInt index = 0;
>
> text = FldGetTextPtr(fld);
>
> if (text != NULL && *text != 0)
> {
>        // it will make a new record to save, how can i make it overwrite
>the existing record??
> textHandle = DmNewRecord(MemoPadDB, &index, StrLen(text) +1);
>
> textPtr = MemHandleLock(textHandle);
>
> DmWrite(textPtr, 0, text, StrLen(text) + 1);
>
> MemHandleUnlock(textHandle);
>
> DmReleaseRecord(MemoPadDB, index, true);
> }
>}
>
>
Here is some code to solve your problem.


static void EditSaveData (FieldPtr fld) {
    CharPtr            text;
    VoidPtr            textPtr;
    VoidHand        textHandle;
    text = FldGetTextPtr (fld);
    if (text != NULL && *text != 0) {

        // CurentRecord is the index of the record you would to rewrite.

        textHandle = DmResizeRecord (MemoPadDB, CurrentRecord, StrLen (text)
+1);

        textPtr = MemHandleLock(textHandle);
        DmWrite (textPtr, 0, text, StrLen (text) +1);
        MemHandleUnlock (textHandle);
        DmReleaseRecord (MemoPadDB, CurrentRecord, true);
    }
}

Javier Moraiz.
E-mail : [EMAIL PROTECTED]


Reply via email to