Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:13:04+00:00 2026-05-25T10:13:04+00:00

I am querying multiple task lists in a SharePoint site. I can retrieve the

  • 0

I am querying multiple task lists in a SharePoint site. I can retrieve the results until I set the Query property and specify the OrderBy clause. The detailed exception and code is pasted below. Appreciate any help

   private void doTasks(SPWeb currentWeb, SPSiteDataQuery q)
    {

        q.Query =
             "<OrderBy>" +
             "   <FieldRef Name='Priority' />" +
             "   <FieldRef Name='DueDate' />" +
             "</OrderBy>";


        // Specify the view fields.
        q.ViewFields = "<FieldRef Name='Title' Type='Text'/>";
        q.ViewFields += "<FieldRef Name='AssignedTo' Type='User' Nullable='TRUE' />";
        q.ViewFields += "<FieldRef Name='PercentComplete' Type='Number' Nullable='TRUE'/>";
        results = currentWeb.GetSiteData(q);

        if (results.Rows.Count > 0)
        {
                 //blah!
        }
    }

[COMException (0x80020009): 0x80020009]
Microsoft.SharePoint.Library.SPRequestInternalClass.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns) +0
Microsoft.SharePoint.Library.SPRequest.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns) +174

[SPException]
Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27428978
Microsoft.SharePoint.Library.SPRequest.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns) +27812419
Microsoft.SharePoint.SPWeb.GetSiteData(SPSiteDataQuery query) +521
StoraEnso.Collaboration.WebParts.SubSiteItemAggregator.SubSiteItemAggregator.doTasks(SPWeb currentWeb, SPSiteDataQuery q) +189
StoraEnso.Collaboration.WebParts.SubSiteItemAggregator.SubSiteItemAggregator.Render(HtmlTextWriter writer) +441
Microsoft.SharePoint.WebPartPages.SPChrome.RenderPartContents(HtmlTextWriter output, WebPart part) +43

[WebPartException]
Microsoft.SharePoint.WebPartPages.SPChrome.RenderPartContents(HtmlTextWriter output, WebPart part) +19826502
Microsoft.SharePoint.WebPartPages.SPChrome.RenderWebPart(HtmlTextWriter output, WebPart part) +64
Microsoft.SharePoint.WebPartPages.WebPartZone.RenderZoneCell(HtmlTextWriter output, Boolean bMoreParts, WebPart part) +1997
Microsoft.SharePoint.WebPartPages.WebPartZone.RenderWebParts(HtmlTextWriter output, ArrayList webParts) +508
Microsoft.SharePoint.WebPartPages.WebPartZone.Render(HtmlTextWriter output) +1000
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +253
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +87
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +53
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.Page.Render(HtmlTextWriter writer) +38
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4240

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:13:05+00:00Added an answer on May 25, 2026 at 10:13 am

    During the migration some page layouts were using the SPSiteDataQuery to query the ContentTypes across different webs to get the content. The code worked fine in SP2007 but in SP2010 it was throwing exception as mentioned below:

    Solution

    Make sure the field your using for the order by is included in the SPSiteDataQuery.ViewFields property. As simple as that!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One can easily use JDO syntax to query on multiple parameters as follows: //specify
Querying a Nested Set Model table , here's the SQL... how can this be
I am querying the Microsoft Office SharePoint Server Search Service to write some results
I`m trying to query all task lists. I have modified default Task content type
I'm new to querying XML datatype in SQL Server 2005. Anyone can help me
A SELECT without a FROM clause gets us a multiple columns without querying a
I have a problem querying multiple tables in MySQL and am currently at my
Django's ORM supports querying from a specific database (when multiple are defined in your
How do you compare enums that have multiple bits set? I must be missing
I have a complex SQL query that joins multiple tables. Here's a watered down

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.