Slide 10.15: Line-by-line anatomy of DB.c (cont.)
  Slide 10.17: Line-by-line anatomy of DB.c (cont.)
  Home


Line-by-line Anatomy of DB.c (Cont.)


StrPrintF( buf, "%ld record(s) still locked.", locks );
This function Int16 StrPrintF( Char *s, const Char *formatStr, ... ) implements a subset of the ANSI C sprintf call, which writes formatted output to a string.
DmCloseDatabase( db );
This function Err DmCloseDatabase( DmOpenRef dbP ) closes a database. This routine does not unlock any records that were left locked. Records and resources should not be left locked. If a record/resource is left locked, you should not use its reference because the record can disappear during a HotSync operation or if the database is deleted by the user. To prevent the DB from being deleted, you can use DmDatabaseProtect( ) before closing.


DmNewRecord( db, &index, sizeof( DBRecordType ) )
This function MemHandle DmNewRecord( DmOpenRef dbP, UInt16 *atP, UInt32 size ) returns a handle to a new record in the database and marks the record busy. Both the busy and dirty bits are set for the new record and a unique ID is automatically created. DmReleaseRecord( ) should be called as soon as the caller finishes viewing or editing the record.