Good morning.
I noticed that many developers have difficulties with Palm's Database manager.
A couple of years ago I wrote some C++ classes that encapsulate the process.
Here is the following code that is required to create and insert a record (I'll
use your data as an example):
// Here we will define your record type
typedef struct
{
char time[15];
char temperature[5];
char comment[20];
} DBRecordType;
// Here is the creation of the database object
DBRecordType DBRecord;
DataBase MyTestDB('NlAc','dat0', sizeof(DBRecord),"TheDB",(char*)&DBRecord);
// Now for the code to insert a record.
StrCopy(DBRecord.time,"test");
NLActionDB.Init();
NLActionDB.FindIDCardNum();
NLActionDB.InsertRecord();
Here is a list of some of the functions supported by my database class:
Init();
Records();
RecordsByID();
FindIDCardNum();
ReadRecord(unsigned short Record);
WriteRecord(unsigned short Record);
ReadRecordByID( unsigned short Record);
ReadSFRecord(unsigned short Record, unsigned char Fields, unsigned short
*RealSize);
InsertRecord();
DeleteRecord(unsigned short Record);
ClearDataBaseByID();
DeleteDataBaseByID();
My database class handles all the dirty details (like memory handles and
opening and closing). I have been using this object library for over 4 years
so it is very stable. If you are interested in obtaining a beta version, let
me know.
Marty
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Klemen Dovrtel
Sent: Sunday, July 03, 2005 5:15 AM
To: Palm Developer Forum
Subject: Database - Writing data to a record
I would like to create a record and then write some data in it. I don't get an
error during compiling, but during program execution.
error: just wrote to a memory location 0x.... which is storage heap. In oreder
to protect integrity of the user's data, such direct access is not allowed.
How should i write the data to a record then?
code:
typedef struct
{
char time[15];
char temperature[5];
char comment[20];
} DBRecordType;
newRecordH=DmNewRecord(gTempDB,&index,sizeof(newRecord));
newRecordP=(DBRecordType*)MemHandleLock(newRecordH);
StrCopy(newRecordP->time,"test");
DmWrite(newRecordP,0,&newRecord,sizeof(newRecord));
MemHandleUnlock(newRecordH);
DmReleaseRecord(gTempDB,index,true);
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/