Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marc Stöcker 104 posts 550 karma points c-trib
    Aug 08, 2013 @ 14:54
    Marc Stöcker
    0

    Using RecordService to delete record results in Exception

    I thought "that will be easy", but now I'm pretty much stuck on something that looked all too easy to accomplish.

    Plan: A workflow that deletes the current record.

    Execution: Custom workflow class (see below)

    Result: Umbraco Exception (DataLayer): SQL helper exception in ExecuteNonQuery

    This is the code

    public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
                {
                    using (RecordService rs = new RecordService(record))
                    {
                        rs.Delete();
                    }
    
                    return WorkflowExecutionStatus.Completed;
                }
    

    Here are the details from UmbracoTraceLog.txt:

    2013-08-08 14:35:08,368 [30] ERROR umbraco.DataLayer.SqlHelper`1[[System.Data.SqlServerCe.SqlCeParameter, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91]] - [Thread 19] Error executing query INSERT INTO UFRecordDataString([key], Value) VALUES(@key, @value)
    SqlCE4Umbraco.SqlCeProviderException: Error running NonQuery: 
    SQL Statement:
    INSERT INTO UFRecordDataString([key], Value) VALUES(@key, @value)
    
    Exception:
    System.Data.SqlServerCe.SqlCeException (0x80004005): A foreign key value cannot be inserted because a corresponding primary key value does not exist. [ Foreign key constraint name = FK_UFRecordDataString_UFRecordFields ]
       bei System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
       bei System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
       bei System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
       bei System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
       bei SqlCE4Umbraco.SqlCeApplicationBlock.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlCeParameter[] commandParameters)
       bei SqlCE4Umbraco.SqlCeApplicationBlock.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlCeParameter[] commandParameters)
       bei SqlCE4Umbraco.SqlCEHelper.ExecuteNonQuery(String commandText, SqlCeParameter[] parameters)
       bei umbraco.DataLayer.SqlHelper`1.ExecuteNonQuery(String commandText, IParameter[] parameters)
    

    Assigned to submit state

    enter image description here

    It seems to me that this issue is reported in a similar manner here:

    http://our.umbraco.org/forum/umbraco-pro/contour/37335-Contour-Workflow-delete-record-database-error

    http://our.umbraco.org/forum/umbraco-pro/contour/23003-workflow-delete-record-not-working

    Any help would be greatly appreciated! :)

    Marc.

  • Tim Geyssens 6526 posts 15308 karma points MVP 2x c-trib
    Aug 14, 2013 @ 11:56
    Tim Geyssens
    0

    Hey,

    Could you try moving the workflow to the approved stage? And let me know if that works, thanks :)

  • Marc Stöcker 104 posts 550 karma points c-trib
    Aug 14, 2013 @ 12:10
    Marc Stöcker
    0

    Sure. Tried that but got an "Object reference not set to an instance" type of error after submitting the form.

    Unfortunately I can't find details/stack trace in UmbracoTraceLog.txt for that error.

  • Tim Geyssens 6526 posts 15308 karma points MVP 2x c-trib
    Aug 14, 2013 @ 12:11
    Tim Geyssens
    0

    Ok thanks, will give it a try and report back later today

  • Tim Geyssens 6526 posts 15308 karma points MVP 2x c-trib
    Aug 14, 2013 @ 14:56
    Tim Geyssens
    100

    Ok fixed the problem so you can upgrade to http://nightly.umbraco.org/Umbraco%20Contour/3.0.15%20WIP/

    But please place the workflow on the approved state otherwise it won't work

    Upgrade instructions can be found here http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Installation/Upgrade

    Didn't spot the forum post last week so next time ping me sooner ;)

  • Marc Stöcker 104 posts 550 karma points c-trib
    Aug 15, 2013 @ 21:53
    Marc Stöcker
    0

    Wasn't too urgent, so I didn't want to be too pushy. :)

    Looks good now with 3.0.15. Working as expected.

    Thanks for your quick help, Tim!

  • Tim Geyssens 6526 posts 15308 karma points MVP 2x c-trib
    Aug 16, 2013 @ 09:11
    Tim Geyssens
    0

    Great, thanks for confirming :)

  • Razvan 36 posts 67 karma points
    Aug 28, 2014 @ 19:58
    Razvan
    0

    I still have this error in contour 3.0.21

    The INSERT statement conflicted with the FOREIGN KEY constraint FKUFRecordDataStringUFRecordFields. The conflict occurred in database, table dbo.UFRecordFields, column 'Key'.\r\nThe statement has been terminated.

  • Robert Brown 18 posts 38 karma points
    Sep 15, 2014 @ 20:37
    Robert Brown
    0

    I also have this error with contour 3.0.21 & v 7.1.6.

    2014-09-15 14:29:17,513 [41] ERROR umbraco.DataLayer.SqlHelper`1[[System.Data.SqlClient.SqlParameter, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] - [Thread 37] Error executing query INSERT INTO UFRecordDataString([key], Value) VALUES(@key, @value)

    System.Data.SqlClient.SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_UFRecordDataString_UFRecordFields". 

     

  • Kevin Lawrence 183 posts 349 karma points
    Sep 18, 2014 @ 10:00
    Kevin Lawrence
    0

    I also receive this error too occasionally (3.0.2.1 & 7.1.1), it's completely random but it's driving us nuts as there doesn't seem to be an obvious reason for it to occur.

    Any news on this one?

Please Sign in or register to post replies

Write your reply to:

Draft