Louise Boulton

Hi everyone,

I'm writing a VSTO 2005 SE add-in for Outlook 2003. It finds the user's contact items by category and compares to a dataset pulled from a SQL Server 2000 database, then if any records in the dataset have been amended, I want it to find the matching contact item. Then if it's a new record for which there's no matching contact item, it creates a contact item, and if the record has been marked as de-activated (e.g. for an employee contact item, their end date field has changed from null to not null), delete and don't re-create. Both these things are working fine. What I also want it to do when records have been changed with updated info say a new mobile phone number, is delete the contact item and create a new one, and it is here that I have encountered a problem. This is my code for this step:
Dim lItems As Outlook.Items = oContacts.Items.Restrict(strLondon)

If Not IsNothing(lItems) Then

Dim lItem As Outlook.ContactItem
Dim lCount As Int16 = 0
For Each drow As DataRow In frmData.SyncData.SpEmployeesSync.Rows
Dim lChanged As Integer = 0 lChanged += 1
If lItem.CustomerID = drow("EmployeeID") Then
Exit For 'exit loop here in order to get back to the next contact item
End If
lItems = Nothing
lItem = Nothing
End Select
End If
The puzzling thing is that this was working fine when I was using the FullName property as a comparator, but then I realised that this approach was flawed because the name itself may change, in which case the code has no chance of running. So I thought I'd use the built in property CustomerID instead, but nothing happens - I change my own name and date parameters in the database, check that the dataset is returning my record with the changed name, but when I run the code although changes to other records are picked up my name change is not.
So if anyone can help I would appreciate it.