Wednesday, 27 February 2013

Error - All items returned by SPQuery

When you form your caml to be used with an SPQuery remember not to include the <Query></Query> tag. Begin with the <Where> tag.

Correct - The following will only return the item with the title "Listitem One":
  • <Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Listitem One</Value></Eq></Where>
Wrong - The following will be some weird reason return all list items:
  • <Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Listitem One</Value></Eq></Where></Query>

No comments:

Post a Comment