Thursday, March 13, 2014

SharePoint 2010 - The data source control failed to execute the insert command

I wanted to take a moment to highlight an extremely helpful post, answered by Siraj regarding the intimidating error "The data source failed to execute the insert command" error in SharePoint 2010. The issue surfaces when customizing the ...\newform.aspx of any list and attempting to submit the completed form. Per his writing, this is the diabolical aftershock of implementing Service Pack 2 on the perspective SharePoint 2010 farm. This was absolutely the crux of the trouble in my case, although I had to take one or two more steps after updating the SharePoint:SPDataSource as he notes (I won't spoil it for you by copying his answer - you can visit his notes for the specific change!).

To fully conquer this trouble, I enacted the following:

  1. Updated the SharePoint:SPDataSource as noted in Siraj's answer
  2. Included ALL required fields in the custom newform.aspx
This second item may not cause as much consternation, but for some forms, I didn't want to populate the "title" field with user input, but rather later with system calculated or concatenated data. For initial releases of SharePoint 2010 up through Service Pack 1, this worked fine to omit "title" from my custom forms. Going forward, this is sadly no longer the case. If you find yourself in similar state of woe, the following will work!

  1. Set a default text value for the affected field in the affected List Settings (This MUST be done via the web GUI, as no one seemingly thought it important enough to include in the Designer column edit tools)
  2. Add the field to the custom newform.aspx
  3. Embed the field within a <div> tag using the following CSS styling to hide it (The exact ID is not important and could be virtually anything, but if left to the system generated Id, it will be something like "ff[Number]{$Pos}"):
    • <div style="display:none">
    • <SharePoint:FormField runat="server" id="ff6{$Pos}" controlmode="New" fieldname="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff6',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}" />
    • </div>
  4. I tested adding the field as an "ASP:TextBox" to enact code-enforced default text rather than setting the default in the List Settings web GUI, but didn't seem to satisfy the mean warnings
That should do it!

No comments:

Post a Comment