Hello
I have a program written, which in its AppStart() (in main.c) I create and
initialize a Database as follows:
gDatabase = DmOpenDatabaseByTypeCreator( kType, kCreator, dmModeReadWrite);
if (!gDatabase)
error = DmGetLastErr();
Handle = DmNewRecord(gDatabase, &index, sizeof(Record));
StrCopy(Record.Username, "NONE");
StrCopy(Record.Password, "NONE");
StrCopy(Record.CheckPass, "NONE");
if (Handle) {
Pointer = MemHandleLock(Handle);
err = DmWrite(Pointer, 0, &Record, sizeof(Record));
MemPtrUnlock(Pointer);
DmReleaseRecord(gDatabase, index, true);
}
Now in the other section of the program (in loginform.c ) I try to access
the database as follows:
static void LoginFormInit(FormPtr form)
{
char string[40];
int NumRecords = DmNumRecords(gDatabase);
StrPrintF(string, "number of records is: %d", NumRecords);
FrmNewLabel(&form, 10000, string, 10,30,0);
// I get one record.
Handle = DmGetRecord(gDatabase, 0);
if (Handle)
p = (DBRecordType *) MemHandleLock (Handle);
}
Now the program works fine within the Palm OS simulator and Emulator, but
when I install the application on my tungsten W, I get this error:
DataMgr.c, Line: 9537, Index out of range. (the system resets after this)
I have figured out that when I take this line out:
if (Handle)
p = (DBRecordType *) MemHandleLock (Handle);
the program will run ok (but obviously this section should work in my
application).
So I have tried several things but I still get an error.
Any help is much appreciated.
Best regards,
Mohammad Afshari
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/