|
Home > Archive > Commerce Server General > July 2005 > Duplicate key values
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Duplicate key values
|
|
|
| I am getting the following error while calling GetProfile
There is a unique contraint on the underlying database. I have checked the
data, there are no duplicates, and no nulls. The field is a nvarchar and
there are no embedded spaces. Any ideas why this is occuring?
ERROR--------------------------
Microsoft.CommerceServer.Runtime.Profiles.CommerceProfileSystemException:
Failed to retrieve profile. ---> System.Runtime.InteropServices.COMException
(0xC1004043): A duplicate value for unique key member
AccountInfo.LostPasswordReference found while building indices for profile
DefaultUser. Check the underlying store for uniqueness of the property. at
Microsoft.CommerceServer.Interop.Profiles.ProfileServiceClass.GetProfileByKey(String
bstrKeyMemberName, Object sValue, String bstrType, Boolean bReturnError) at
Microsoft.CommerceServer.Runtime.Profiles.Profile..ctor(ProfileContext
profileService, String keyName, String keyValue, String profileType)
| |
| David Hargis [MSFT] 2005-07-26, 5:53 pm |
|
It sounds like you are encountering a known problem with the caching layer
of the profile system. The problem originates from an attempt to create a
profile that contains a UNIQUE index and, for some reason or another,
encounters an error when trying to persist the data to the underlying store
(i.e. when Profile.Update() is called). Because of the caching layer of
the profile system, this bad profile remains in the cache, even though the
Save failed. Then, the error you are seeing below pops up when the UNIQUE
property of the bad profile conflicts with the UNIQUE property of a valid
profile you are attempting to create or update.
There are a few things you can do to minimize these errors / prevent them:
Quick symptom reliev: reduce the cache entry expiration time of the
profile service. This won't prevent anything, but will reduce the amount
of time the bad profile remains in the cache.
Solution: Any time you encounter an error when calling Profile.Update(),
call Profile.Refresh() in the catch block. For example:
public void SaveUpdate(Profile p)
{
try
{
p.Update();
}
catch (CommerceException)
{
try
{
p.Refresh();
}
catch (CommerceException) {}
throw;
}
}
The Refresh() call should remove any bad entries from the cache
immediately. The inner try...catch is needed because Profile.Refresh()
will throw an exception if the Profile object has not been committed to any
underlying store (i.e. first-time save).
Hope this helps,
David
--------------------
Thread-Topic: Duplicate key values
thread-index: AcWHsGAJ0FKByM/fSJKgk//uZzXXyQ==
X-WBNR-Posting-Host: 24.89.198.192
From: =?Utf-8?B?UGVy?= <Per@discussions.microsoft.com>
Subject: Duplicate key values
Date: Wed, 13 Jul 2005 06:40:04 -0700
Lines: 16
Message-ID: <2EAA5E68-19F0-4092-AA99-6C4066663EFF@microsoft.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.commerceserver.general
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.commerceserver.general:3003
X-Tomcat-NG: microsoft.public.commerceserver.general
I am getting the following error while calling GetProfile
There is a unique contraint on the underlying database. I have checked the
data, there are no duplicates, and no nulls. The field is a nvarchar and
there are no embedded spaces. Any ideas why this is occuring?
ERROR--------------------------
Microsoft.CommerceServer.Runtime.Profiles.CommerceProfileSystemException:
Failed to retrieve profile. --->
System.Runtime.InteropServices.COMException
(0xC1004043): A duplicate value for unique key member
AccountInfo.LostPasswordReference found while building indices for profile
DefaultUser. Check the underlying store for uniqueness of the property. at
Microsoft.CommerceServer.Interop.Profiles.ProfileServiceClass.GetProfileByKe
y(String
bstrKeyMemberName, Object sValue, String bstrType, Boolean bReturnError) at
Microsoft.CommerceServer.Runtime.Profiles.Profile..ctor(ProfileContext
profileService, String keyName, String keyValue, String profileType)
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
|
|
|
|
|