Hal,

Well Actually I have written this for my application but I'm getting an error, 
and my code doesnt seem to work. below is my code:

I call two function to open two database in the AppStart():

err = MLGetUserDatabase(&gmlUserDB, mode);
err = MLGetChaptersDatabase(&gmlChaptersDB, mode);

-------------------------

Err MLGetUserDatabase (DmOpenRef *dbP, UInt16 mode)
{
    Err        error = errNone;
    DmOpenRef  db;
    UInt16     cardNo;
    LocalID    dbID;
    UInt16     attributes;
    UInt16     dbVersion;


    *dbP = NULL;
    
    dbID = DmFindDatabase(0, mlUserDBName);
    
    if ( dbID )
        db = DmOpenDatabase(0, dbID, mode);

    if (! db)
    {
        error = DmCreateDatabase(0, mlUserDBName, appFileCreator, 
mlDBType, false);
       
        if (error) 
            return error;
      
        dbID = DmFindDatabase(0, mlUserDBName);
        db = DmOpenDatabase(0, dbID, mode);
              
        if (! db) 
            return (1);
       
     *dbP = db;
    return errNone; 
}



Err MLGetChaptersDatabase (DmOpenRef *dbP, UInt16 mode)
{
    Err        error = errNone;
    DmOpenRef  db;
    UInt16     cardNo;
    LocalID    dbID;
    UInt16     attributes;
    UInt16     dbVersion;

    *dbP = NULL;
 
    dbID = DmFindDatabase(0, mlChaptersDBName);
    
    if ( dbID )
        db = DmOpenDatabase(0, dbID, mode);
        
    if (! db)
    {
        error = DmCreateDatabase(0, mlChaptersDBName, appFileCreator, mlDBType, 
false);
        if (error) 
            return error;
        
        dbID = DmFindDatabase(0, mlChaptersDBName);
        db = DmOpenDatabase(0, dbID, mode);
                
         if (! db) 
            return (1);

    *dbP = db;
    return errNone; 
}


-----------

And at the end of the application I closes both of the databases
-------------


When I run my application in the simulator, it goes into the 
application without error, then when I view the databases for the application 
only the first database the "gmlUserDB" is created, and when I quit the 
application I get this error:

"Error: Free Ptr"

followed by:

"Bad DBRef"...

Any help is much appreciated.

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

Reply via email to