Hi Mohammad,
what happens, if the DmFindDatabase fails? You test for an uninitialized
variable db to be NULL. If you only declare the variable (DmOpenRef db;) but
do not initialize it (db = NULL;) then db may contain any value.
Use
DmOpenRef db = NULL;
instead and doublecheck any other variable if you use it without
initialization.
Am Freitag, 13. Oktober 2006 00:07 schrieb Mohammad Afshari:
> 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;
> }
>
> [...]
--
Mit freundlichen Grüßen
Helmut A. Bender
Helmut Bender GmbH
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/