Can someone help me understand the update and delete statements generated by the tableadapter wizard in vs2005 ?
UPDATE [dbo].[Person] SET [PersonID] = @PersonID, [EmployeeNumber] = @EmployeeNumber, [Lastname] = @Lastname, [Firstname] = @Firstname,[Email] = @Email WHERE (([PersonID] = @Original_PersonID) AND ([EmployeeNumber] = @Original_EmployeeNumber) AND ([Lastname] = @Original_Lastname) AND ([Firstname] = @Original_Firstname) AND ((@IsNull_Email = 1 AND[Email] IS NULL) OR ([Email] = @Original_Email)));
This statement is used on my Person-TableAdapter. When an existing person has a registered email address it is working fine, but when the email address is NULL in the db(sql server 2005). I am getting an System.Data.DBConcurrencyException and the message : Concurrency violation: the UpdateCommand affected 0 of the expected 1 records, when trying to update the person with an email address.
The reason whyI am getting this is the WHERE statement : (@IsNull_Email = 1 AND[Email] IS NULL) OR ([Email] = @Original_Email). When I am updating the person the @isNull_Email is not equals 1 but 0, since I am sending in an email address and then the first part fails (@IsNull_Email = 1 AND[Email] IS NULL) .
The second part of the WHERE statement is also failing because Email is not = NULL but Email IS NULL..
What am I missing here?To me it seems like there should be an @IsNull_Original_Email parameter..