I am writing an application that contains 4 databases. On startup I open all 4 (and create if they don't already exist). I am finding however that when closing the program, an exception occurs. In particular, when running the program in the emulator, the following error is displayed upon closing the application:
"Hardware exception #2 occurred while the emulator was calling the Palm OS function DmOpenDatabaseInfo."
However, if I only open 1 of the 4 databases, everything works correctly - the error only occurs when at least 2 databases are opened. Here is my code to initialise each database:
// OPENS AND INITIALISES DATABASE
Err DBInitialise(DmOpenRef *db, UInt32 type, UInt32 creator, char *name, Boolean resource, UInt16 appinfostr) {
MemHandle handle;
Err error;
RecordCounter = 0; TypeCounter = 0;
error = 0;
*db = DmOpenDatabaseByTypeCreator(type, creator, dmModeReadWrite);
if (!*db) {
error = DmCreateDatabase(0, name, creator, type, resource);
if (error != errNone) {
return error;
} *db = DmOpenDatabaseByTypeCreator(type, creator, dmModeReadWrite);
if (!*db) {
return DmGetLastErr();
}
error = DBInitialiseApplicationInfo(*db, appinfostr);} return error; }
// INITIALISES APPLICATION INFORMATION
Err DBInitialiseApplicationInfo(DmOpenRef db, UInt16 appinfostr) {LocalID dbID; LocalID appInfoID; UInt cardNo; UInt attributes;
AppInfoPtr appInfoPtr; MemHandle handle;
handle = NULL;
if (DmOpenDatabaseInfo(db, &dbID, NULL, NULL, &cardNo, NULL)) {
return dmErrInvalidParam;
}if (DmDatabaseInfo(cardNo, dbID, NULL, &attributes, NULL, NULL, NULL, NULL, NULL, &appInfoID, NULL, NULL, NULL)) {
return dmErrInvalidParam;
}
if (appInfoID == NULL) {
handle = DmNewHandle(db, sizeof(AppInfoType));
if (!handle) {
return dmErrMemError;
}appInfoID = MemHandleToLocalID(handle);
DmSetDatabaseInfo(cardNo, dbID, NULL, &attributes, NULL, NULL, NULL, NULL, NULL, &appInfoID, NULL, NULL, NULL);
}
appInfoPtr = MemLocalIDToLockedPtr(appInfoID, cardNo); DmSet(appInfoPtr, 0, sizeof(AppInfoType), 0); CategoryInitialize(appInfoPtr, appinfostr);
MemPtrUnlock(appInfoPtr); return 0; }
Each database has the same creator ID (i.e. the application creator ID), but different types. I'm calling the DBInitialise function during startup of the application for each database that is being opened.
Is there anything different that needs to be done to allow multiple databases to be opened at the same time?
Any help on this would be greatly appreciated.
- Kyle
_________________________________________________________________
Personalise your mobile chart ringtones and polyphonics. Go to http://ringtones.com.au/ninemsn/control?page=/ninemsn/main.jsp
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
