Richard,
You need to use DmWrite() to write to your database. The memory returned by
DmNewHandle() is write protected and can only be written to using DmWrite()
or DmSet() (and a few others).
Your code should do something like this ..
DmWrite(recP, 0, &newEntry, sizeof(newEntry));
Also do you really mean ..
> &recP->DriverLogRec.ind = &newEntry.ind;
You should get a compile error or warning from this, Im sure.
You also should set the indexOfInsert variable to the record index you wish
to insert at or dmMaxRecordIndex to append to the end.
Cheers
---------------------------
Steve Fillingham
CodeDrive Pty Ltd
[EMAIL PROTECTED]
"Richard.Johnstone" <[EMAIL PROTECTED]> wrote in message
news:31712@palm-dev-forum...
>
> I am trying to insert a record into the database.
> The insert works in the right place etc.
> The problem is the data is the record is all wrong. I am passing in a
> structure and then assigning these values to the record I am trying to
> insert.
> Can I do this?? When I create the recP using DmNewHandle, will what is
> stored in recP be stored in the database when I store the handle??
>
>
> void insertNewRecord(DriverLogEntryType newEntry) {
> // insert the new record into the database
> Err err;
> VoidPtr recH;
> BothRecordsPtr recP;
> UInt32 structSize = 0;
>
> // get the size of the structure
> structSize = sizeof(DriverLogEntryType);
> // create a new handle
> recH = DmNewHandle(DriversLogDB, structSize);
>
> recP = MemHandleLock(recH);
>
> // copy the values into the field.
> &recP->DriverLogRec.ind = &newEntry.ind;
> recP->DriverLogRec.Id = newEntry.Id;
> recP->DriverLogRec.TripDetailsId = newEntry.TripDetailsId;
> recP->DriverLogRec.PeriodTimestamp = newEntry.PeriodTimestamp;
> StrCopy(recP->DriverLogRec.DutyStatusCode, newEntry.DutyStatusCode);
>
> err = DmAttachRecord(DriversLogDB, &indexOfInsert, recH, NULL);
> MemHandleUnlock(recH);
>
> }
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/