No, I don't use DmAttachRecord, I just release the record, and I always
use DmHandleUnlock before a MemHandleFree. I checked it.
My code to add records:
iNumRec=dmMaxRecordIndex;
hNewRec = DmNewRecord(PVOrder,&iNumRec,1);
if (hNovoReg)
{
PackOrder(RegOrder, hNewRec);
DmReleaseRecord(PVOrder,iNumRec,true);
NumRecsOrder++;
}
else...
static void PackOrder(StruRegPed *RecOrderTemp, VoidHand hOrderDB)
{
UInt iSize = 0;
CharPtr sOrder;
UInt offset = 0;
iSize = StrLen(RecOrderTemp->NrOrder) + 1 +
StrLen(RecOrderTemp->CdCus) + 1 +
StrLen(RecOrderTemp->Vl) + 1;
if (MemHandleResize(hOrderDB, iSize) == 0)
{
sOrder = MemHandleLock(hOrderDB);
offset = 0;
DmWrite(sOrder, offset, (CharPtr)RecOrderTemp->NrOrder,
sizeof(RecOrderTemp->NrOrder));
offset = StrLen(RecOrderTemp->NrOrder) + 1;
DmStrCopy(sOrder, offset, (CharPtr) RecOrderTemp->CdCus);
offset += StrLen(RecOrderTemp->CdCus)+ 1;
DmStrCopy(sOrder, offset, (CharPtr) RecOrderTemp->Vl);
offset += StrLen(RecOrderTemp->Vl);
MemHandleUnlock(hOrderDB);
}
}
Danny Epstein wrote:
>
> "Roberto Amorim" <[EMAIL PROTECTED]> wrote in message
> news:9594@palm-dev-forum...
> > HandleOrder = DmQueryRecord(PVOrder, PedRegCorr);
> >
> > Error = DmGetLastErr();
> > ErrFatalDisplayIf(Error, "Unable to locate Order");
> > *****This test returned Error=zero*******
> >
> > RecTempOrder = MemHandleLock(HandleOrder);
> > ****The error now is here "Invalid Handle"*****
>
> I normally check if the result of DmQueryRecord is null rather than using
> DmGetLastErr, although either should work as far as I can tell.
>
> It looks like you managed to put an invalid handle into a database or you
> freed a handle that contains a database record. Are you using
> DmAttachRecord? Are you calling MemHandleFree or MemPtrFree on a chunk
> containing a database record (without detaching it)?
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html