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


===================================================================
������ѵ������� (http://mail.sina.com.cn)
���������-MP3����ͨDVD�ֻ��������������ṩ����������� 
(http://newchat.sina.com.cn/love/)

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