SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a code with an XML query that I believe is correct but for some reason, when I type anything into the web apps search textbox, it appears to filter but actually just pulls 100 of the rows at random (?)...Does anyone see anything wrong with my query or know why a query would ever filter at random maxing out at 100?

public DataTable GetSPData(string SearchStr)
   ISSTechCommService.Lists ListService = new ISSTechCommService.Lists();
   ListService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
   ListService.Url = "";

   XmlDocument xmlDoc = new System.Xml.XmlDocument();

   XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
   XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
   XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

   ndQueryOptions.InnerXml =
        "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
   ndViewFields.InnerXml =    
            "<FieldRef Name='Is_x0020_Active' />" +
            "<FieldRef Name='PublicationItem' />" +
            "<FieldRef Name='Release_x0020_Title' />" +
            "<FieldRef Name='Summary' />" +
            "<FieldRef Name='Media_x0020_Type1' />" +
            "<FieldRef Name='Release_x0020_Date' />" +
            "<FieldRef Name='Internal_x0020_URL' />" +
            "<FieldRef Name='External_x0020_URL' />" +
            "<FieldRef Name='Number' />" +
            "<FieldRef Name='Distribution' />";

ndQuery.InnerXml = "<where><contains><FieldRef Name='Distribution' /><value Type='TEXT'>" + SearchStr + "</value></contains></where>";

DataTable objTable = new DataTable();       
      XmlNode ndRequestNode = ListService.GetListItems("Roadmap", null, ndQuery, ndViewFields, null, ndQueryOptions, null);

        XmlNodeReader ndReader = new XmlNodeReader(ndRequestNode);

        DataSet objDS = new DataSet();
        if (objDS.Tables.Count > 1) objTable = objDS.Tables[1];

        // dispose the web service object


    catch (System.Web.Services.Protocols.SoapException ex)
        throw new Exception(ex.InnerException.Message);
        return objTable;
share|improve this question

I can't answer your question about "at random", but I can answer you about the 100 items. That is the build in maximum of items that is retrieved when no rowlimit is specified. When you specify a value of, for example, 10.000, that amount of items is returned. I wouldn't consider that a best practice, determine for yourself: how many items do i need at max.

another thing that i miss, is an order of items. You could, for example, order your items by date, descending. Your newest addition would be on top, and the items that are returend, would become predictable.

share|improve this answer
Thanks Bas...I believe it may just be pulling the top 100 so the real question comes down to WHY it isn't filtering as it should based on the searched text.. – Sarah Feb 27 '12 at 4:44

The queries are picky about casing. E.g. <where><contains><FieldRef Name='Distribution' /><value Type='TEXT'> should be <Where><Contains><FieldRef Name='Distribution' /><Value Type='Text'> (With appropriate closing fields of course).

When there's an error in the query it will ignore the query, and give you what it would have without the query.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.