The data source control failed to execute the insert command
While working on a custom form the other day, we noticed the form that was working fine was suddenly throwing the following error:
“The data source control failed to execute the insert command”
Without anything to go off of we started comparing version history in the form, comparing source control versions, searching online, nothing really worked. It ended up being a combination of several things.
First, make sure your XSLT databinding parameter matches the type of databinding you’re doing. For example, there are three types of databinding parameters available in the SharePoint:FormField control:
i = Insert Used for NewForm pages
u = Update Used for EditForm pages
d = Delete Self-explanatory
Therefore, if you’re adding a FormField control to a NewForm page, you wouldn’t want to use the ‘u’ parameter in the ddwrt:DataBind() function, it should be as follows:
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="New" FieldName="FieldName" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@FieldName')}" />
Likewise, your EditForm page would look like this:
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="FieldName" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@FieldName')}" />
In addition to this, the other issue was there were site columns that were deleted but still being referenced in the form template. Either locating those site columns in the template and commenting them out or removing them altogether, or re-adding them to the site columns page solved the problem.
Another possibility I found was after applying an update (or through changes from troubleshooting) you may find the SPDataSource for the form’s DFWP is changed to:
<SharePoint:SPDataSource runat="server" DataSourceMode="List"
The DataSourceMode is supposed to be:
<SharePoint:SPDataSource runat="server" DataSourceMode="ListItem"
There could be other reasons for this error, feel free to add them to the comments below. Hope this helps!