"Stadin, Benjamin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I use the below code to write records to the db. The problem occurs at the line (at the end) > DmStrCopy(p, StrLen(keyn) +8 +1, note); > > This raises a "DmWriteCheck failed" error when the String in (Char *) note is larger than 27 chracters. > > Any ideas? > > Btw I read the text from a field and store it into Char * note. Char * keyn is the first 40 characters of the same text. > > Greets > Benjamin > > > Char * note; > Char * keyn; > > fldLen = FldGetTextLength(fld); > note = MemPtrNew (fldLen + 1); > GetFieldText (EditView, EditMemoField, note); > > if (fldLen >= 40) > { > keyn = MemPtrNew (41); > StrNCopy (keyn, note, 40); > } > else > { > keyn = MemPtrNew (StrLen(note) + 1); > StrCopy (keyn, note); > } > > h = DmGetRecord (MemoDB, CurrentRecord); > p = MemHandleLock (h); > u32Value = 0; > DmWrite (p, 0, &u32Value, 4); // noteLength > DmWrite (p, 4, &u32Value, 4); // reserved > DmStrCopy(p, 8, keyn); > DmStrCopy(p, StrLen(keyn) +8 +1, note); > > MemHandleUnlock (h); > DmReleaseRecord (MemoDB, CurrentRecord, dirty); >
Didn't look at your code in any great detail but, StrNCopy does not null terminate your string.- you have to do that yourself. Also, why don't you set up a structure for your record instead of playing around with magic numbers for offsets? Bound to shoot yourself in the foot this way. Ralph -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
