The Problem is in Dmwrite Statement ...
It won't write the Structure directly..
Try to write each member of your record independently
..

For Ex:


offset = 0;
error
=DmWrite(textPtr,offset,(CharPtr)&fin->indicator,
sizeof(fin->indicator));

offset+=sizeof(fin->indicator);
for next member increase the offset accordingly ...


Regards,
Manish
--- Anne Srinivas <[EMAIL PROTECTED]>
wrote:
> Hai,
> 
> I need to write and read a structure to a database.
> I am able to write that structure to a database with
> out an error.
> But when i try to read that structure , i am getting
> all sort of junk
> values.
> 
> Here is the code i am referring to
> 
> Definition of structure:
> ----------------------
> typedef struct final
> {
>           short   indicator;
>           int p;
> }final;
> 
> 
> Procedure for writing:
> ----------------------
> // fin is an instanace of final
> // values are loaded into fin
> //All the var's are appropriately initialised
> //points is reference to database
> 
> textHandle = DmNewRecord(points, &index,
> sizeof(final));
> textPtr = MemHandleLock(textHandle);
> 
> error=DmWrite(textPtr,0,&fin,sizeof(fin));
> 
> 
> Procedure for reading:
> ----------------------
> final *rec;
> rec=(final*)MemHandleLock(recHandle);
> 
> But the values in rec are junk!!
> Now , which of these procedures are wrong ?
> Is it the reading one or the writing one?
> 
> Can structures be written this way?
> Or should i write to offset or a recors?
> 
> Any help will be greatly appreciated.
> 
> Thanks  in advance.
> 
> Regard's
> --
> Anne Srinivas
> Software Engineer
> InfoTech Enterprises Ltd.
> Plot No 11,Infocity,
> Software Units Layout,
> Madhapur,Hyderabad 33
> 
> E-Mail :
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> 
> Tel (Resi)   : 3033761
> 
> 
> 
> 
> 
> 
> -- 
> For information on using the Palm Developer Forums,
> or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/


__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/

-- 
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