I have several dictionaries i populate from a database here is some sample of database
all fileds in DB are represented as strings
PromoStatus 3 Paid
PromoStatus 4 Escrowed
TickTransCode &H0 Valid cashable ticket
TickTransCode &H1 Valid restricted promo ticket
TickTransCode &H2 Valid nonrestricted promo ticket
BIllDenom 0 1
BIllDenom 1 2
here is code i have
Public Shared TickTransCode As New Dictionary(Of Byte, String)()
Public Shared BIllDenom As New Dictionary(Of Byte, Decimal)()
Public Shared PromoStatus As New Dictionary(Of Byte, String)()
Dim myReader As SqlDataReader = Nothing
Dim myCommand As New SqlCommand("select * from dictionary", myConnection)
myReader = myCommand.ExecuteReader()
While myReader.Read()
Select Case myReader.GetString(2)
Case "PromoStatus"
PromoStatus.Add(Convert.ToByte(myReader.GetString(3)), myReader.GetString(4))
Case "BillDenom"
BIllDenom.Add(Convert.ToByte(myReader.GetString(3)), Convert.ToByte(myReader.GetString(4)))
Case "TickTransCode"
TickTransCode.Add((myReader.GetString(3)), myReader.GetString(4))
End Select
End While
the first to cases work fine the 3 case i am not sure the proper conversion so &HA should actually be 10 &HF would be 15 etc. you may ask why i dont just put the actual number in DB but the Hex number is what i get from the comm stream and number the documention uses so i need to keep same so dont have to convert every number when trouble shooting data issues.
here is error i get
Input string was not in a correct format
also is there a better way to do the dictionary from a database, I have far many more dictionaries than in this sample to be populated and i really dont want a table for each one. reason i using DB is so i can add to dictionaries without having to recompile and also to put some additional languages for prompts and messages etc that can load and or change at run timeat run time
NumberStyles.HexNumber does not allow “&h” or “&H”. However, you can remove them simply: