From: Sridhar Venkataraman [mailto:[EMAIL PROTECTED]]
> Whenever, i create and open a database and insert records
> into it, everything is fine. I am able to read the records
> and display them. But when i exit the application and again
> run it, the records are not being read. The number of records
> stored is correct but  i can find only junk in the records.

Without even looking at your code, I will guess that you are storing a
pointer (probably to a character string) in the record, rather than a copy
of the pointed-to bytes.  That's no good since pointers are generally not
persistable across app invocations.

> recordH = DmQueryRecord (dbMainRef, i);
> MyRecType = (Maindbrec *) MemHandleLock (recordH);
> hand = MemPtrRecoverHandle ((MemPtr) MyRecType->fileno);
> MemHandleLock (hand);

What's this?  It appears you have stored a pointer in your record, and the
MemPtrRecoverHandle call indicates it was originally a pointer to a heap
allocated chunk.  If so, this scheme can't possibly work.  That heap chunk
got freed and recycled at least when your app exited the first time, if not
before that.

To store character strings in a db record, you must copy the bytes directly
into the record.  Storing pointers or handles in records doesn't work.
Think about the lifetimes of memory objects, and the reason should become
clear.

-slj-



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to