this question is related to this Multidimensional Associative Array in VB.NET
getting the following error.
System.ArgumentException: An item with the same key has already been added.
Line 103: AdInsured.Add(dbread.Item(“FullName”), New Person(dbread.Item(“FullName”), GetAge(dbread.Item(“DateOfBirth”))))
Dim AdInsured As New Dictionary(Of String, Person)()
Do While dbread.HasRows
AdInsured.Add(dbread.Item("FullName"), New Person(dbread.Item("FullName"), GetAge(dbread.Item("DateOfBirth"))))
Loop
The key in a Dictionary must be unique. If you have an item with the key “John” and try to add one more with the same key you get this exception. You will need to make sure that each item in the dictionary is given a unique key. You can check whether a key is already used in the dictionary: