Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Violation of PRIMARY KEY constraint 'pk_metadata'.
System
I am working on a project to update the metadata in MediaBin but, I rec'd a "Violation of PRIMARY KEY constraint 'pk_metadata'." I'll paste the code below and then the error from mbp.log.
********** Begin: Main function Code **********
// Search and set the metadata //
String[] assetsString = _mediaBinServer.Search_GetAssetIDsOnly(mbSearchCriteria);
if (assetsString.Length == 0)
{
MessageBoxDisplay.Show("All save actions have been cancelled because the image (" + mediaRefIDHexString + ") could not be found in MediaBin at container " + mbSearchCriteria.mContainerID + " and could not be updated.", MessageBoxDisplayType.Error);
return false;
}
else
{
// Build metadata to update //
MBMetadata[] revisionsMBMetadata = new MBMetadata[5];
revisionsMBMetadata[0] = SaveMediaBinValues_AddMetaData("{F40AEBB6-F7F1-41D3-AA88-D40F30E48C3F}", "provider test");
revisionsMBMetadata[1] = SaveMediaBinValues_AddMetaData("{503F0B0C-734E-4C87-BA7A-84762465A635}", "image caption test");
revisionsMBMetadata[2] = SaveMediaBinValues_AddMetaData("{4DA442CE-FA09-4A73-8472-E588C05DF47B}", "photographer credit string test");
revisionsMBMetadata[3] = SaveMediaBinValues_AddMetaData("{666927B6-C474-4EED-B4D4-C4F17A063C8D}", "provider credit string test");
revisionsMBMetadata[4] = SaveMediaBinValues_AddMetaData("{F40AEBB6-F7F1-41D3-AA88-D40F30E48C3F}", "provider test");
// Update the metadata //
try
{
_mediaBinServer.ReviseAssetMetadata(assetsString[0], revisionsMBMetadata);
return true;
}
catch (MBException mbException)
{
MessageBoxDisplay.Show("An unexpected error occurred while trying to update the MediaBin metadata on image: " + mediaRefIDHexString + ". Error: " + mbException.Message, MessageBoxDisplayType.Error);
return false;
}
}
********** End: Main function Code **********
********** Begin: SaveMediaBinValues_AddMetaData function Code **********
private MBMetadata SaveMediaBinValues_AddMetaData(String newMetaDataID, String newValue)
//==============================================================================
// Purpose : Create a new search constraint for MediaBin SearchCriteria
//
// Notes : If the GetMetadata() fails, error will be thrown upwards
//
// History :
//------------------------------------------------------------------------------
// Date Developer Description
//------------------------------------------------------------------------------
// 2006-10-24 stacyhan Initial Creation
// Notes: 1) None
//==============================================================================
{
try
{
MBMetadata mbMetadata = new MBMetadata();
mbMetadata = _mediaBinServer.GetMetadata(newMetaDataID);
mbMetadata.mValue = newValue;
return mbMetadata;
}
catch (Exception exception)
{
{
MessageBoxDisplay.Show("An unexpected error occurred while building the search constraints for search criteria. Please modify your Search Constraints and try again.\n\n" + exception.Message, MessageBoxDisplayType.Error);
}
}
// Nothing as fall-through //
return null;
}
********** End: SaveMediaBinValues_AddMetaData function Code **********
*** Mbp.Log ***
12/06/06 17:01:29 Error in WriteBlob()
12/06/06 17:01:29 Error with SQL: insert into metadata ( factoryid, revisionid, datatype, datavalue ) values ( ?, ?, ?, ? )
12/06/06 17:01:29 Violation of PRIMARY KEY constraint 'pk_metadata'. Cannot insert duplicate key in object 'metadata'.
The statement has been terminated.
State:23000,Native:2627,Origin:[Microsoft][ODBC SQL Server Driver][SQL Server]
State:01000,Native:3621,Origin:[Microsoft][ODBC SQL Server Driver][SQL Server]
Find more posts tagged with
Comments
There are no comments yet