Batch insert failed: Telerik.OpenAccess.RT.sql.SQLException: Violation of PRIMARY KEY constraint 'pk_sf_prmssons_inheritance_map'.
I tried to upload one pdf document in custom module but sometimes i encountered this below shown error but not all the times .
Batch insert failed: Telerik.OpenAccess.RT.sql.SQLException: Violation of PRIMARY KEY constraint 'pk_sf_prmssons_inheritance_map'. Cannot insert duplicate key in object 'dbo.sf_permissions_inheritance_map'.
Violation of PRIMARY KEY constraint 'pk_sf_prmssons_inheritance_map'. Cannot insert duplicate key in object 'dbo.sf_permissions_inheritance_map'.
The statement has been terminated.
The statement has been terminated. ---> System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'pk_sf_prmssons_inheritance_map'. Cannot insert duplicate key in object 'dbo.sf_permissions_inheritance_map'.
Violation of PRIMARY KEY constraint 'pk_sf_prmssons_inheritance_map'. Cannot insert duplicate key in object 'dbo.sf_permissions_inheritance_map'.
The statement has been terminated.
The statement has been terminated.
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows)
at OpenAccessRuntime.Intellitrace.Update(String id, DbDataAdapter adapter, DataRow[] rows)
at Telerik.OpenAccess.RT.sql.Batch.Perform(String connId, DbDataAdapter adapter, DataRow[] rows)
at Telerik.OpenAccess.Runtime.Logging.LoggingDbCommand.ExecuteBatch(DbDataAdapter adapter, DataRow[] rows, Batch batch)
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)
--- End of inner exception stack trace ---
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)
at Telerik.OpenAccess.RT.sql.Batch.ExecuteBatchDataTable(Boolean withInfo)
INSERT INTO [sf_permissions_inheritance_map] ([sf_prmssons_inheritance_map_id], [child_object_id], [child_object_type_name], [object_id]) VALUES (@p0, @p1, @p2, @p3)
Batch Entry 0 (set event logging to all to see parameter data)
Hi Krishnamorrthy,
Could you please provide more information about the custom module? Is this is a module created by the build-in Module builder, generated by Sitefinity Thunder or it is a custom module?
If it is not created by the Module Builder is there any special reason that you are not using it? What is the scenario that you are trying to achieve? Using Module builder you can create a Content type with custom field of type related media - Documents and other files.
Regards,
Svetoslav Manchev
Telerik
Hi Svet,
We are using custom modules for reason handle database performance.Not in build-in module builder modules or Sitefinity Thundar. On that particular case, we upload some .pdf files to document and files module using c#. The below mentioned code was worked fine. But, sometimes we facing duplicates errors when save the changes.
libraryManager.SaveChanges();
using (new ElevatedModeRegion(libraryManager)) // get library by specified Name DocumentLibrary parentLibrary = libraryManager.GetDocumentLibraries() .Where(k => k.Title == selectedLibrary).FirstOrDefault(); // create an image content item Document testContent = null;
if (parentLibrary != null)
testContent = libraryManager.CreateDocument(); // specify parent library the image will belong to testContent.Parent = parentLibrary;
testContent.MimeType = mimeType;
testContent.Title = fileName;
testContent.LastModified = DateTime.UtcNow;
testContent.DateCreated = DateTime.UtcNow;
testContent.UrlName = Regex.Replace(fileName.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); try
libraryManager.RecompileAndValidateUrls(testContent);
libraryManager.Upload(testContent, file.InputStream, ".pdf"); libraryManager.Publish(testContent);
libraryManager.SaveChanges();
var bag = new Dictionary<string, string>();
bag.Add("ContentType", typeof(Document).FullName); WorkflowManager.MessageWorkflow(testContent.Id, typeof(Document), null, "Publish", false, bag);
catch (Exception ex)
Response.Write("There is an exception");
Hello Krishnamorrthy,
Can you provide us with more information about the scenario you have. It will be helpful if you provide us with the custom module and the steps tho reproduce it more stable (by opening of support ticket for the issue, for example).
From other hand, this code seems not directly related to custom module. Do you have this error using the code outside your custom module using this code snippet for documents upload?
Regards,
Svetoslav Manchev
Telerik