1. Call DmWriteCheck yourself to see what error code it returned.  It can return
dmErrNotValidRecord, dmErrWriteOutOfBounds, or errNone. Determining what it
thinks the problem is might help.

2. If it returns dmErrNotValidRecord, the pointer you're passing in to
DmWriteCheck is invalid.  This could mean that DmGetRecord failed.  Perhaps the
record is busy or deleted.  You should check the returned handle to see if it's
NULL, and call DmGetLastErr to find out what the error was.

3. If it returns dmErrWriteOutOfBounds, that would mean that the record size is
too small, which in turn would mean the DmResizeRecord failed for some reason.

-- Keith






hymanho <[EMAIL PROTECTED]> on 02/19/2001 12:01:10 AM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  hymanho <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/US/PALM)
Subject:  DmWriteCheck failed



Hello,

    I have a big problem for my palm program. in my program, I let user input
two field and save the value into the database.

but it always show "DmWrite:DmWriteCheck failed" when I insert a longer value
than before into the database. how can I handle this?

following is my code:

Err SaveUserProfile(Char *UserID, Char *Passwd)
{
     Char *ProductID, *tmp="";
     Err error;
     DmOpenRef dbRef;
     Char      *pMypointer, *pCurrPos;
     int numRecs=0, indx=0, SerialLen=0;
     MemHandle   recH;
     MemPtr    recP;

     tmp = GetSerialNum(&SerialLen);
     ProductID = new char[SerialLen];
     StrNCopy(ProductID, tmp, SerialLen);

     error = CheckOrgeDB();
     if ( error >= 0 )
     {
          dbRef = OpenDBByName(DBNAME,MODE);
          if (dbRef)
          {
               numRecs = DmNumRecords(dbRef);
               pMypointer = (Char *)MemPtrNew(500);
               pCurrPos  = pMypointer;

               StrCopy(pCurrPos, UserID);
               pCurrPos += StrLen(UserID) + 1;

               StrCopy(pCurrPos, Passwd);
               pCurrPos += StrLen(Passwd) + 1;

               StrCopy(pCurrPos, ProductID);
               pCurrPos += StrLen(ProductID) + 1;

               if ( numRecs > 0 )
               {
                    int fsize = pCurrPos - pMypointer;

                    DmResizeRecord( dbRef, 0, (pCurrPos - pMypointer));
                    recH = DmGetRecord( dbRef, 0 );
                    recP = MemHandleLock(recH);
                    error = DmWrite (recP, 0 , pMypointer , (pCurrPos -
pMypointer));

                    if (error)
                         FrmAlert(Profile_WriteRec_Alert);

                    MemHandleUnlock(recH);
                    DmReleaseRecord( dbRef, 0, true);
                    profile_data_modify = false;
               } else{
                         recH = DmNewRecord(dbRef,0,(pCurrPos-pMypointer));
                         recP = MemHandleLock(recH);
                         indx = 0;
                         error = DmWrite (recP, 0 , pMypointer , (pCurrPos -
pMypointer));
                         if (error)
                              FrmAlert(Profile_InsertRec_Alert);

                         MemHandleUnlock(recH);
                         DmReleaseRecord( dbRef, 0, true);
                         profile_data_modify = false;
               }

               MemPtrFree(pMypointer );
               DmCloseDatabase(dbRef);
          }
     }
     return 1;
}

Best regard

Hyman He
[EMAIL PROTECTED]



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