In my app. I want to check to see if a database exists, if it doesn't I want to create 
it.  Can
someone look at the code below and tell me if this is the best way to handle this task?

Thanks,
Ed.

DmOpenRef gSRCatDB = 0;
#define kSRCatDB_DBName     "myDB"
#define kCreator            "TEST"
#define kDBType             "DATA"

gSRCatDB = DmOpenDatabase(0, DmFindDatabase(0,kSRCatDB_DBName), dmModeReadWrite);

/* If it doesn't exist, create it. */
if (!gSRCatDB) {
    error = DmCreateDatabase(0, kSRCatDB_DBName, kCreator, kDBType, false);

    if (error)
       return error;

    /* If there is no error creating the database, open it. */
    gSRCatDB = DmOpenDatabase(0, DmFindDatabase(0,kSRCatDB_DBName), dmModeReadWrite);

    if (!gSRCatDB)
       return DmGetLastErr();
}



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

Reply via email to