I have an enumerated list of integers, which I'm trying to read from a SqlDataReader and pass into a method as an argument.
Because I have the "Option Strict On", the IDE is complaining that I must convert the value to the enumerated value (the list is already declared as an integer!?!??!
My enumerated list:
Reading in the value:Code:Public Enum StockItemType As Integer INGREDIENT = 0 PACKAGING = 1 UTENSIL = 2 End Enum
My method (instantiates a new class object):Code:While rdrSQL.Read() Me.Items.Add(New StockItem(.GetInt32(0), .GetString(1), .GetInt32(2))) End While
I've tried CInt, but that still prompts the error. The database value has been changed from a TinyInt value to an Int, just to see if it would resolve the problem but unfortunately, not so.Code:Public Sub New(ByVal ID As Integer, Optional ByVal Name As String = "", Optional ByVal StockType As StockItemType = StockItemType.INGREDIENT) Initialize(ID, Name) End Sub
Any ideas? Any help would be greatly appreciated.
P.S. Advice on having the database value set to a TinyInt value, and still having the enumerated list construct and method/argument still working would also be of great help!
Thanks.




Reply With Quote