[odb-users] MS SQL Foreign Key Error

Boris Kolpackov boris at codesynthesis.com
Mon Apr 1 11:32:08 EDT 2013

Hi Dean,

Dean Throop <DThroop at PacificCabinets.com> writes:

> My memory profiler though indicates that it was still in state and 
> accessible in the main.

It may be accessible (it is part of the stack) but it will most likely
contain garbage.

> Below are my tables.

I took a look and I don't see any problems. So it is most likely that
the productType member points to an object (or, rather a piece of memory)
that contains garbage instead of a valid ItemTypes object id. To verify,
you can print it just before calling db->update().

On a side note, when working with an existing schema, it is a good idea
to explicitly assign column name and type to every data member, to
avoid any inconsistencies. For example:

  #pragma db id auto column("ID") type("int")
  int id;


More information about the odb-users mailing list