use
else {
 err=DmCreateDatabase(

rater than

if(!gDatabase) {
 err=DmCreateDatabase(

LionScribe

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Mauricio Martins - CLARO DIGITAL
Sent: Wednesday, August 27, 2003 9:38 AM
To: Palm Developer Forum
Subject: Error on opening database


HiHo,

        This is my first mail to this list.

        Well, I'm new in development for PalmOS and I getting a curious
error when I try to open a Database. See the piece of code (several FrmAlert
was inserted to help me where is the error). I tried the piece of code shown
in Palm Code Recipes and gave the same error Sys (0004) and the handler
gDatabase is almost NULL;
        When I delete the database, the creation goes without problem. Since
database is created, and I start the application the error occurs.
        My development environment is prc-tools 2.2, pilrc 2.9, sdk4.0
running on Win2k. POSE 3.5 emulating a m505 with PalmOS 4.0.


        Thanks a lot! :)

        Mauricio

>------------------------------------------
#define kType 'DATA'
#define kCreator 'pMMC'
#define kCardNumber 0
#define kName "testDB"

DmOpenRef gDatabase; // Global

static void StartApplication() {
    Err err;

    LocalID dbId=DmFindDatabase(0,kName);
    if(dbId)
        gDatabase=DmOpenDatabase(0,dbId,dmModeReadWrite);

    if(!gDatabase) {
        err=DmCreateDatabase(
                kCardNumber,kName,kCreator,kType,false);
        if(!err) {  // Created...
            dbId=DmFindDatabase(0,kName); // find again...
            if(dbId) // found (it must. I created before!!!)
                gDatabase=DmOpenDatabase(0,dbId,dmModeReadWrite); // Open it

            if(!gDatabase) { // Hell what's happening!!!
                err=DmGetLastErr();
                ErrAlert(err);
            }
        } else
            ErrAlert(err);
    } else {
        ErrAlert(err);
    }

    ...
}

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



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

Reply via email to