Why does the following code result in my MemHandle newRecordH being equal to
0x00000000? and ultimately throwing an exception?
#include "AddToDB.h"
#define DBType 'DATA'
#define CreatorID 'IDPT'
#define DBName "LSDB"
DmOpenRef glibDB;
Err error = 0;
UInt16 index = 0;
UInt16 mode;
Err InitDB()
{
glibDB = DmOpenDatabaseByTypeCreator(DBType,CreatorID,mode);
if (!glibDB)
{
error = DmCreateDatabase(0,DBName,CreatorID,DBType,false);
if (error)
return error;
glibDB = DmOpenDatabaseByTypeCreator(DBType,CreatorID,mode);
if (!glibDB)
return DmGetLastErr();
}
return error;
}
void AddTextFileToDB(char* NewFile)
{
TextFile newRecord;
MemHandle newRecordH;
TextFile* newRecordP;
newRecord.body = NewFile;
newRecordH = DmNewRecord(glibDB,&index,sizeof(newRecord)); //Error
Line!!!!!!!
newRecordP = (TextFile*)MemHandleLock(newRecordH);
DmWrite(newRecordP,0,&newRecord,sizeof(newRecord));
MemHandleUnlock(newRecordH);
DmReleaseRecord(glibDB,index,false);
++index;
}
--
Thanks in advance
--
Nikue Harlley
Veni Vidi Vici
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/