Column value changes when row is added RRS feed

  • Question

  • User2098947605 posted

    Here's a strange one...

    I'm adding a record to a sqlserverce database.  The field datatype is Integer, and when the .AddRow method is called the value changes from 4 to 2.  Must be a conversion issue, however, I get the same results with the following datatypes: short, Int16, and Int32.  When I debug oRow.Item("Tag")  contains 4 after line 6, but then it changes to 2 after line 7!

    Any ideas what i can do here, anyone?

     Here's some code:

    1 enum Vals as Integer

    2  Added= 4

    3 end enum

    4 sub test() 

    5  Dim oRow As DataRow = DataTable1.NewRow

    6  oRow.Item("Tag") = Vals.Added

    7  DataTable1.Rows.Add(oRow)

    8 end sub


    Monday, November 6, 2006 6:09 PM

All replies

  • User2026204247 posted


    Try to set integer value instead of enumeration value.

    Like this:

    oRow.Item("Tag") = 4

    If it's work try CInt function for convertation.

    Otherwise you have table definition problem.

    Best Regards.



    Tuesday, November 7, 2006 7:19 AM