Hi Ravindra
Until last time i have such problems: when i change a record, DmWriteCheckFailed Error
appears. Because i obtain a handle to � necessary record with help of DmGetRecord.
DmGetRecord return a handle to a record by index and mark the record BUSY. If record
is BUSY, DmWriteCheck return dmErrNotValidRecord because it's impossible to resize and
write to a record. Because need to use DmQueryRecord function.
Follow function allow to write block data (BodyRec with size BodyLen) to a new record
(routine=0) or change having (routine=1).
//-------------------------------------------------------------------------
void WriteToDB(UInt16 routine,UInt16 nNumRecord,unsigned char *BodyRec,UInt32 BodyLen)
{
MemHandle RecHandle;
MemPtr RecPtr,MemPtr;
UInt16 NumRecord,NumRec1;
Err dmErr;
if (routine==0)
{
NumRecord=DmNumRecordsInCategory(DB,dmAllCategories);
NumRec1=NumRecord;
if (!NumRecord) {
NumRecord=0;NumRec1=0;
RecHandle=DmNewRecord(DB,&NumRec1,BodyLen+1);
}
else RecHandle=DmNewRecord(DB,&NumRec1,BodyLen+1);
}
if (routine==1) {RecHandle=DmQueryRecord(DB,nNumRecord);NumRecord=nNumRecord;}
RecPtr=MemHandleLock(RecHandle);
MemPtr=MemPtrNew(BodyLen+1);
MemSet(MemPtr,BodyLen+1,0);
MemMove(MemPtr,BodyRec,BodyLen);
dmErr=DmWriteCheck(RecPtr,0,BodyLen+1);
if (dmErr==dmErrWriteOutOfBounds) {
MemPtrUnlock(RecPtr);
RecHandle=DmResizeRecord (DB,NumRecord,BodyLen+1);
RecPtr=MemHandleLock(RecHandle);
}
DmWrite(RecPtr,0,MemPtr,BodyLen+1);
MemPtrUnlock(RecPtr);
DmReleaseRecord(DB,NumRecord,false);
}
Best regards, Vladimir Shakin ([EMAIL PROTECTED])
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/