Hi,
You need to ceate duplicate detection rules in data management section of CRM 4. then you need to write following code where you are updating your entity. This code specifies whether an entity instance will be created or updated if a duplicate is found.
// Create operation – do not create, if a duplicate exists.
CreateRequest reqcreate = new CreateRequest();
reqcreate.OptionalParameters = new OptionalParameter[] { new CreateDuplicatesOptionalParameter(false) };
// Update operation – do not update, if a duplicate exists.
UpdateRequest requpdate = new UpdateRequest();
requpdate.OptionalParameters = new OptionalParameter[] { new CreateDuplicatesOptionalParameter(false) };