Here is the open routine

static Err Open(void)
{
        // Open the database or create it if it doesn't exist:
        if(dbPtr == NULL)
        {
                // First see if we can find it:
                LocalID dbID = DmFindDatabase(DB_CARDNO, DB_NAME);
                if(!dbID)
                {
                        // Couldn't find it, so create it:
                        Err err = DmCreateDatabase(DB_CARDNO, DB_NAME, 
DB_CREATOR, DB_TYPE, false);
                        if(err)
                                return err;
                        // Now we ought to find it:
                        dbID = DmFindDatabase(DB_CARDNO, DB_NAME);
                        if(!dbID)
                                return 1;
                }
                // Found it, now open it:
                dbPtr = DmOpenDatabase(DB_CARDNO, dbID, dmModeReadWrite);
                if(dbPtr == NULL)
                        return 1;
        }
        // Everything went smoothly:
        return 0;
}


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

Reply via email to