Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inserting into a database

0 views
Skip to first unread message

Chris Tacke

unread,
Mar 7, 2001, 6:29:31 PM3/7/01
to
I'm trying to insert data into a database that is two "columns": string data
followed by an integer. Logically it would look like this:

Adams*4325

Smithfield*32

Johnson*323

etc.

where "*" is a null byte.

I'm using:

<ccode>

// get handle to new record

hRecord = DmNewRecord(currentIndex, &position, insertSize);


// lock it

pRecord = MemHandleLock(hRecord);


// clear it

DmSet(pRecord, 0, insertSize, 0);

// copy in the data

DmStrCopy(pRecord, offset, pContact->Fields[contactLastName]); // Char *

offset += StrLen(pContact->Fields[contactLastName]) + 1;

DmWrite(pRecord, offset, &pContact->DBIndex, sizeof(pContact->DBIndex));
//UInt16


// unlock handle

MemHandleUnlock(hRecord);

// release record

DmReleaseRecord(currentIndex, position, true);

</ccode>

It's storing the string fine, but failing to store the integer. Where am I
going wrong here?

-------------------------------

Christopher Tacke, MCSD

Associate, Rubicon Technologies

(703) 713-1640 ext 319

Hari Bhaskaran

unread,
Mar 8, 2001, 7:55:48 AM3/8/01
to
1. What is the initial value of offset?
2. Do you know it really doesn't write the integer? Have you used
a program like resedit to view the database? It could be that
you are reading it wrong!
3. While reading it back if you'r type-casting the record pointer to get
to the integer, you should note that Word (UInt16) and DWord (UInt32)
pointers cannot start at an odd offset - it will generate a bus error.
Instead if you'r using MemMove to copy the value out, you should be OK.

"Chris Tacke" <cta...@rtmobile.com> wrote in message
news:Mss1u61...@www.massena.com...

0 new messages