Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding and removing items in collection
Message
De
26/10/2015 13:38:21
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Adding and removing items in collection
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01626445
Message ID:
01626445
Vues:
62
I have a collection. I add them using a unique identifier. However, before adding a new one, I verify something. If that is the case, I remove the related item from the collection, by using its key, update something in its content, and insert the item back into the collection by using the same key.

So, it goes like this:
' Get the item from the collection
loObject = oInnerJoin.Item(lnKey)

' Remove the item from the collection
oInnerJoin.Remove(lnKey)

' Set the search criteria to True
loObject(1) = True

' Add the updated item in the collection
oInnerJoin.Add(loObject, lnKey, 1)
So, in a specific logic, this is executed three times on the same key. The first two times, it works. I see the collection item being removed and added back with the object loObject(1) item. However, on the third time, it gives this:

"Add failed. Duplicate key value supplied."

Anyone would be able to explain that?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform