What wrong in this CDO code ?

Started by TimoVJL, April 18, 2012, 01:35:28 PM

Previous topic - Next topic

TimoVJL

This attached code works with msvc 2008, but not with PellesC.
Field Update with error code 0x800A0EA5.

From MSDN:
The Fields update failed. For further information, examine the Status property of individual field objects.

Have anyone time to check it ?

If you define TEST and compile it with speed optimization, it may work,
but not with no optimizations.
May the source be with you

aardvajk

Quote
vArg1.vt = VT_INT;
vArg1.iVal = iVal;
VT_INT means machine sized int, variant.iVal is for shorts/VT_I2. You want:
Quote
vArg1.vt = VT_INT;
vArg1.intVal = iVal;
It works on one and not the other presumably because the rubbish in the high word of intVal is a different value. It happens to be 0 where it works, and non-zero where it doesn't (giving you a value that's not 1 or 2).

You'd think VariantInit would initialize the whole variant but it doesn't, it only sets variant.vt = VT_EMPTY, it doesn't touch the data part of the variant.

FYI: You might know, but just in case - Your declaration of Field is missing quite a few functions (including the status function mentioned in the error message), and the parameter to Field::get_Properties is a struct ADOProperties **, not a DISPID*.

TimoVJL

May the source be with you