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/

Reply via email to