The record was probably deleted by call to DmDeleteRecord().
This call deletes the data portion, but leaves the header around
(just to let the conduit know that there was such a record
once upon a time). If you are not using a conduit and it is your
source code that deletes the record, you should use
DmRemoveRecord() instead.

Since your program reads databases from other programs,
you should develop a habit of calling DmRecordInfo() to see
if it is a "deleted" record before you go to read it.

--
Hari Warrier

"ccoleman" <[EMAIL PROTECTED]> wrote in message
news:29082@palm-dev-forum...
>
>      Hello,
>
>      I'm writing an application that will allow the user to browse around
>      through all the databases on the Palm and view a listing of the sizes
>      of each record in a selected database. Except for while viewing one
>      particular database, the application works perfectly.
>
>      The problem that I'm encountering is that when I try to check the
size
>      of the Giraffe High Score database's single entry, I get a Fatal
>      Exception. I could just prevent the user from trying to view this
>      database in particular, but I'm concerned that there may be other
apps
>      out there with databases that cause the same problem.
>
>      Here is the snippet of code that is causing me problems:
>
>      ---------------------------------------------------------------------
-
>
>      UInt32                          nRecordSize ;
>      MemHandle                       RecordHandle ;
>      DmOpenRef                       dbCurrentDatabase ;
>
>      ...
>
>      dbCurrentDatabase  =  DmOpenDatabase ( pCurrentItem->nCardNo,
>                                             pCurrentItem->localID,
>                                             dmModeReadOnly ) ;
>
>      ...
>
>      // Note that if dbCurrentDatabase is NULL, we don't get to this
point.
>
>      RecordHandle  =  DmQueryRecord ( dbCurrentDatabase,
>                                       nIndex ) ;// nIndex is 0 in this
case
>
>      if ( RecordHandle == NULL )
>      {
>          StrCopy ( sBuffer, "0 bytes" ) ;
>      }
>      else
>      {
>          nRecordSize  =  MemHandleSize ( RecordHandle ) ;
>          // Fatal Exception reported on above line
>
>          StrPrintF ( sBuffer,
>                      "%lu bytes",
>                      nRecordSize ) ;
>      }
>
>      ---------------------------------------------------------------------
-
>
>      In the CodeWarrior debugger, I can see that RecordHandle is
definitely
>      not NULL, but pressing the plus next to it shows that what it points
>      to (labeled as *RecordHandle) has a value of -1. Normal handles seem
>      to have positive values. I tried to check if ( *RecordHandle < 0 ) to
>      prevent this handle from being passed to MemHandleSize, but just
>      de-referencing the handle in the code causes the fatal exception.
>
>      Does anyone know if there's a way I can check the validity of a
handle
>      that isn't NULL? There doesn't seem to be any function out there that
>      will do this. Most of the time, it seems that DmQueryRecord either
>      returns NULL or a valid handle.
>
>      If no one has any ideas about that, is there something special about
>      the Giraffe High Score database? Maybe it's stored in a special area
>      of memory? If so, is there a way I can determine that in code?
>
>      Thanks,
>         Curt Coleman
>         [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