InvalidCastException

Posts   
 
    
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 15-Aug-2007 15:06:17   

        /// <summary> The XmitStation property of the Entity Mitarbeiter<br/><br/>
        /// </summary>
        /// <remarks>Mapped on  table field: "Mitarbeiter"."xmit_station"<br/>
        /// Table field type characteristics (type, precision, scale, length): Integer, 0, 0, 1<br/>
        /// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
        public virtual Nullable<System.Int32> XmitStation
        {
            get
            {
                object valueToReturn = base.GetCurrentFieldValue((int)MitarbeiterFieldIndex.XmitStation);

                return (Nullable<System.Int32>)valueToReturn;
            }
            set { SetNewFieldValue((int)MitarbeiterFieldIndex.XmitStation, value); }
        }

return (Nullable<System.Int32>)valueToReturn; << causes the exception confused . The value of valueToReturn is 1.

.Net type System.Int32 DB type Decimal Length 1 Precision 0 Scale 0.

Any suggestions out there?

Regards, Carlo

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 15-Aug-2007 15:14:43   

Are you using the Adapter or SelfServicing model? Which runtime library version are you using? (ref: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725)

Please make sure you refresh the catalog from the Designer, then re-generate the code. And then make sure your application is indeed using the newly generated code, rather than some older one.

Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 15-Aug-2007 18:09:02   

Walaa wrote:

Are you using the Adapter or SelfServicing model?

Adapter scenario

Walaa wrote:

Which runtime library version are you using? (ref: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725)

Yes I know, that is the reason why I have it in my signature. .> LLBLGen 2.0, 6th December 2006.

I have solved the problem by myself. The problem is, that the oledb provider for vfp delivers the precision -1 (I think for the comma, but that´s wrong). I have modified the foxpro database driver for llblgen and now it works. I add always 1 to the precision if it is a decimal data type, regardless of the scale. It doesn´t look good in llblgen but it works for me.

VFP -> budget, numeric, 10, 2 LLBLGEN -> budget, decimal, 10, 2

VFP -> status, numeric, 1, 0 LLBLGEN -> status, decimal, 2, 0 frowning

Regards, Carlo