Sharepoint Designer Dataview Webpart Errors

I recently spent several days trying to solve a Sharepoint / Sharepoint Designer problem and thought I would share the solution here.

 

Symptom 1

A web part page with a dataview web part that connected to a SQL Server datasource was giving the following error message and stack trace:

Server Error in ‘/’ Application

The type is not registered as safe

Stack Trace:

 

[UnsafeControlException: The type is not registered as safe.]

   Microsoft.SharePoint.EditingPageParser.VerifyControlOnSafeList(String dscXml, RegisterDirectiveManager registerDirectiveManager, SPWeb web) +948

   Microsoft.SharePoint.WebPartPages.DataFormWebPart.get_DataSources() +186

   Microsoft.SharePoint.WebPartPages.DataFormWebPart.AddDataSourceControls() +69

   Microsoft.SharePoint.WebPartPages.DataFormWebPart.CreateChildControls() +1583

   System.Web.UI.Control.EnsureChildControls() +87

   System.Web.UI.Control.PreRenderRecursiveInternal() +44

   System.Web.UI.WebControls.WebParts.WebPart.PreRenderRecursiveInternal() +42

   System.Web.UI.Control.PreRenderRecursiveInternal() +171

   System.Web.UI.Control.PreRenderRecursiveInternal() +171

   System.Web.UI.Control.PreRenderRecursiveInternal() +171

   System.Web.UI.Control.PreRenderRecursiveInternal() +171

   System.Web.UI.Control.PreRenderRecursiveInternal() +171

   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

The Sharepoint site had many pages with similar dataview web parts, and most of these were still working. The only clear difference with this one was that it was connected to a form web part on the page.

Symptom 2

After opening the Sharepoint site, or any of its subsites, I was unable to view data for either existing database connections or new database connections. For example, when clicking Manage Data Sources, I could see the database connection that had been defined. If I clicked the drop down box and chose ‘Show Data’, I received the following error:

“The server returned a non-specific error when trying to get data from the data source. Check the format and content of your query and try again. If the problem persists, contact the server administrator.”

If I tried to define a new database connection, I could connect to the database, and I could see the schema because a list of tables was being returned. However, as soon as I clicked ‘Show Data’ I got the same error above.

Root Cause

The problem was a missing section of XML in the web.config file that defines the SQL Data Sources. The web.config file was the first place I looked, since the ‘Type is not registered as safe’ usually means there is not a safe control entry in the file. However, in this case, the control was not a custom web part, it was a default Sharepoint web part, and it looked like all of the defaults were listed in Safe Controls.

After doing some file comparisons with some older web.config files, we discovered that the following code was missing from the current web.config file.

<pages enableSessionState="false" enableViewState="true" enableViewStateMac="true" validateRequest="false" pageParserFilterType="Microsoft.SharePoint.ApplicationRuntime.SPPageParserFilter, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" asyncTimeout="30">
 <namespaces>
 <remove namespace="System.Web.UI.WebControls.WebParts" />
 </namespaces>
 <tagMapping>
  <add tagType="System.Web.UI.WebControls.SqlDataSource, System.Web,  Version=2.0.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"
mappedTagType="Microsoft.SharePoint.WebControls.SPSqlDataSource, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
 </tagMapping>
</pages>

We were able to trace the problem back to a web part installation of Lightning Tools Forum that happened a couple of weeks ago. The Lightning Tools Forum web part consisted of two features. One of them was a .Net Framework 3.5 Feature that added all of the entries needed for .Net 3.5 into the web.config file. We had some problems with this feature, and during troubleshooting, it was activated and deactivated several times. So either the deactivation removed the section, or it was accidentally removed by me in the process. (On a side note, We got the Lightning Tools Forum web part to work without the .net 3.5 feature)

Random Posts

Loading…

Leave a Reply