NO

Author Topic: What wrong in this CDO code ?  (Read 3327 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
What wrong in this CDO code ?
« on: April 18, 2012, 01:35:28 PM »
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

  • Guest
Re: What wrong in this CDO code ?
« Reply #1 on: April 18, 2012, 10:55:33 PM »
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*.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: What wrong in this CDO code ?
« Reply #2 on: April 19, 2012, 07:44:19 AM »
Thanks aardvajk.
May the source be with you