Groups > Microsoft > Microsoft Speech Tech SDK > Assigning a CString to lpwstr




Assigning a CString to lpwstr

Assigning a CString to lpwstr
Wed, 19 Dec 2007 21:58:22 -080
Hello,

I am trying to read a record from CE database and update one of
properties of the record with new value. To update the record, I am
doing the following...

MyFunctionToWriteOrUpdateRecord(record,oid)
{
     CEPROPVAL *prgPropVal= record.NewPropVal();
    CEOID id = CeWriteRecordProps(
		m_hDB,				// handle to database
		oid,					// update a record
		1,					// five properties
		prgPropVal);		// propval structure

	record.DeletePropVal(prgPropVal);
}
and in NewPropVal() I do the following..

CEPROPVAL *CRecord3::NewPropVal(void)
{
	CEPROPVAL *prgPropVal = new CEPROPVAL[7];
	ZeroMemory(prgPropVal, sizeof(CEPROPVAL[7]));

	prgPropVal[0].propid = MAKELONG(CEVT_LPWSTR, 1);
	prgPropVal[0].val.lpwstr = m_userN.LockBuffer();
        ....
        ....
        ....  //Similar operations for other propeties also


	return prgPropVal;
}

However, the prgPropVal[0].val.lpwstr does not contain correct data.
Hence, in DB a record with junk values gets added. Can anybody please
explain why this happens and what i should be doing to correct this
behaviour.

Thanks in advance,
Post Reply
about | contact