Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27388

How do I check if a value exist before adding it to avoid duplicates?

$
0
0
The code I have pasted here is adding NCIC number (nc:IdentificationID) and ProtectionOrderOtherIdentificationTypeCode (NCICNUM). However I want to add a For Each to loop and check if the NCIC number (nc:IdentificationID) exist before adding it.

If the NCIC number is found, that number cannot be added because I do not want duplicates. Otherwise if the number is not found, another number can be added as long as it is not a duplicate.

The exception message for the duplicate value should look like this:
Protection Order[PO number goes here] already has NCIC number[NCIC number from MNCIS].

Example of error message
Protection Order 1400456 already has NCIC number 87654321 associated with it

I am not sure how to do this. Can someone help?

Here is my code:

Code:

'Process other identification

objXmlCrossReferenceNode = aobjXmlInputDoc.DocumentElement.SelectSingleNode("ext:ProtectionOrderOtherIdentification", objXMLNameSpaceManager)

If Not objXmlCrossReferenceNode Is Nothing Then 'objProtectionOrder.AddCrossReferenceNumber(objXmlCrossReferenceNode.SelectSingleNode("ext:ProtectionOrderOtherIdentificationTypeCode", objXMLNameSpaceManager).InnerText, objXmlCrossReferenceNode.SelectSingleNode("nc:IdentificationID", objXMLNameSpaceManager).InnerText)
objProtectionOrder.AddCrossReferenceNumber(objXmlCrossReferenceNode.SelectSingleNode("nc:IdentificationID", objXMLNameSpaceManager).InnerText, objXmlCrossReferenceNode.SelectSingleNode("ext:ProtectionOrderOtherIdentificationTypeCode", objXMLNameSpaceManager).InnerText)
End If


Viewing all articles
Browse latest Browse all 27388

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>