Records start at 0.  You've hardcoded '1' to DmQueryRecord().  Maybe that's
your problem?

> ----------
> From:         [EMAIL PROTECTED][SMTP:[EMAIL PROTECTED]]
> Reply To:     Palm Developer Forum
> Sent:         Tuesday, January 09, 2001 11:42 AM
> To:   Palm Developer Forum
> Subject:      Retrieve Record Blank
> 
> Hi, 
> 
> May be some of you can help me out with my problem. I am using codewarrior
> and developing a simple application that would save
> string from textfield into database for later use. The string length
> is unknown. For some reason, when I retrieve the record from the 
> database, it always return blank. Insider show that the database does
> have the record. I use "test" as the string to test it. 
> Here is what I use to save the record:
> 
> static Boolean AddRecord()
> {
>       FormPtr frmP;
>       FieldPtr url1fldP;
>       Char * url1Str;
>       
>       frmP = FrmGetActiveForm();
>       url1fldP = FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, 1204));
>       url1Str = FldGetTextPtr(url1fldP);
>       
>       if (url1Str == NULL)
>       {
>               FrmAlert (DataIncompleteAlert);
>               return false;
>       }
>       else
>       {
>               Handle h;
>               UInt numberRecord = DmNumRecords(gDatabase);
>               UInt index;
>               UInt slength;
>                               
>               if (numberRecord == 0)
>               {       
>                               
>                       index = dmMaxRecordIndex;
>                       slength = StrLen(url1Str) + 1;
>                       h = DmNewRecord(gDatabase, &index, slength);
>                       if (h) 
>                       { // could fail due to out of memory!
>                       Ptr p = MemHandleLock(h);

>                       Err err = DmWrite(p, 0, &url1Str, slength);
>                       MemPtrUnlock(p);
>                       DmReleaseRecord(gDatabase, index, true);
>                       }       
>                               
>               }
>       }
>       return true;
> }
> 
> 
> Here is what I do to get the record:
> 
> static Boolean GetRecord()
> {
> 
>       Handle h;
>       //FieldPtr fldP;
>       FormPtr frm = FrmGetActiveForm();
>       Char recordAsString[5];
>       h = DmQueryRecord(gDatabase, 1);
>       if (h) {
>                       Char * record = MemHandleLock(h);
>                       StrCopy(recordAsString, record);
>                       //fldP = FrmGetObjectPtr(frm, 1204);
>                       //MemHandleUnlock(h);
>       }
>       return true;
> }
> 
> At this point, the debugger show that record == "" and recordAsString =
> "". h does has data, 
> 
> why is record blank ? Hope someone can help as I am new to this. Thanks so
> much in advance.
> 
> Darren
> 
> 
> -- 
> For information on using the Palm Developer Forums, or to unsubscribe,
> please see http://www.palmos.com/dev/tech/support/forums/
> 

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