I am not sure why you are getting a null handle for DmNewRecord, but you
have some C issues.  You are saving a structure of pointers to the db which
may or may not be valid when you open the database record the next time.  If
you change your structure to use char arrays, you can write it directly to
the db in one call using DmWrite.  Otherwise you will have to use some
string packing mechanism - there are plenty of examples of that around.

Make sure your OpenDatabase function returns a valid DmOpenRef handle.

-Dave



"R Moon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I have a problem,
> this function add a record to Database
> but when i execute DmNewRecord the MemHandle obtain 0x00000000
> and error is MemHandle NULL
> I have a fucntion, open DB
>
> Boolean other function
> {
> OpenDatabase(&Database);
> AddNewREcord(Database); //call the function to add record
> }
>
> static Err AddNewRecord(DmOpenRef db)
> {
>  UInt16        recordIndex = DmNumRecords(db) + 1 //dmMaxRecordIndex;
>    PacienteStruc  newRecord;
>    MemHandle     myRecordHandle;
>    PacienteStruc  *newRecordPtr;
>    Err      err;
>    newRecord.Nombre = "Bill";
>    newRecord.Apellidos = "Mother";
>    newRecord.Dia = "1";
>    newRecord.Mes = "1";
>    newRecord.Anio = "1";
>    newRecord.Sexo = "M";
>    newRecord.PatPrev = "I Heat DmNewRecord";
>
>   myRecordHandle = DmNewRecord(db, &recordIndex, sizeof(newRecord));
>   newRecordPtr = MemHandleLock(myRecordHandle);
>   err = DmWrite(newRecordPtr, 0, &newRecord, sizeof(newRecord));
>   MemHandleUnlock(myRecordHandle);
>   return err;
> }
>
> the struct is
> typedef struct PacienteStruc
> {
>  Char *Nombre ;
>  Char *Apellidos;
>  Char *Dia ;
>  Char *Mes ;
>  Char *Anio ;
>  Char *Sexo ;
>  Char *PatPrev;
> } PacienteStruc ;
>
> typedef PacienteStruc* PacienteStrucPtr;
> -- 
> Rub�n Luna Cabret
>
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to