I'm developing for the first time on Palm OS and I'm looking for causes/answers to 
peculiar problems I'm having. 

Code listing below.

Basically, on app startup I open one database, and sort it if necessary. The 
application exits if this first database does not exist. 

Startup continues by checking for a second database. If the second database does not 
exist, I create it then open it. 

My intention is to have both databases open and ready for use simultaneously. 

First of all is this possible? I'm assuming I can have two databases open at the same 
time.

Second, this is the peculiar part, the first time setup is run, that is, the case 
where the second database does not exist, and is created, after exiting the program 
and going to "Applications Home" then 'Info", I find that the second databse was not 
created, and that the first database was in fact renamed to the second database. At 
least it's the name of the second database that shows up in the "Info" list. However, 
when the program is run again, DmFind has no problem finding the first database name. 

By the way, this is on a Palm OS 3.0 device. 

I'm confused and any help would be greatly appreciated. I'm guessing I'm making a 
stupid mistake, but I can't find any reference to why this wouldn't work. 

Thanks,
Nick.


Code sample.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.

        dbID = DmFindDatabase(0, productDbName);
        if (dbID == 0) {
                FrmAlert( MissingDatabaseAlert );
                return -1;
        }
        
        gDb = DmOpenDatabase(0, dbID, dmModeReadWrite);
        if (! gDb) {
                ErrAlert(DmGetLastErr());
                return DmGetLastErr();
        }

        
        error = DmDatabaseInfo(0, dbID, NULL, NULL, &dbVersion, 
                                                 NULL, NULL, NULL, NULL, NULL, NULL, 
NULL, NULL);
        if (error) {
                return DmGetLastErr();
        }

        if ( (!prefs.databaseSorted) || (dbVersion == 0) ) {
        
                RectangleType box = { 20, 60, 120, 40 };
                WinDrawRectangle( &box, 4 );
                FntSetFont( boldFont );
                WinEraseChars( "Please Wait..", 13, 48, 74 );
                error = DmInsertionSort( gDb, (DmComparF *)&ListCompareRecords, 1 );
                WinEraseWindow();
                prefs.databaseSorted = true;
                
                
        }
        
        dbVersion = 1.0;
        error = DmSetDatabaseInfo(0, dbID, NULL, NULL, &dbVersion, 
                                                 NULL, NULL, NULL, NULL, NULL, NULL, 
NULL, NULL);
        if (error) {
                ErrAlert(DmGetLastErr());
                return DmGetLastErr();
        }
        
        PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, 
                                                   &prefs, sizeof (prefs), true);
        
        ordDbID = DmFindDatabase(0, orderDbName);
        
        if (ordDbID == 0) {
                error = DmCreateDatabase(0, orderDbName, appFileCreator, 'ordr', 
false);
                
                if (error ) {
                        ErrAlert(error);
                        return error;
                
                }
                        
                ordDbID = DmFindDatabase(0, orderDbName);
                if (ordDbID == 0) {
                        ErrAlert(DmGetLastErr());
                        return error;
                }
                        
        }
        
        ordDb = DmOpenDatabase(0, ordDbID, dmModeReadWrite);
        if (! ordDb) {
                ErrAlert(DmGetLastErr());
                return DmGetLastErr();
        }
                                
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


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

Reply via email to