Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Error if using <Neq> tag more than 2 times

  Asked By: Pankaj    Date: Sep 11    Category: Sharepoint    Views: 904

I am getting error when I add more than two "<Neq>" tags in "<And>" tag in
CAML query. Please see the example below, Example 1 is working fine because it
has only two <Neq> tags and Example 2 is not working (showing error:"Cannot
complete this action. Please try again.").
Example 1:
SPQuery
spQuery.Query =
"<Neq><FieldRef Name='Status'/><Value
Type='Text'>Closed</Value></Neq>"+"<Neq><FieldRef Name='Status'/><Value
Type='Text'>Fixed</Value></Neq>"+
"</And></Where>";
Example 2:SPQuery
spQuery.Query =
"<Neq><FieldRef Name='Status'/><Value
Type='Text'>Closed</Value></Neq>"+"<Neq><FieldRef Name='Status'/><Value
Type='Text'>Fixed</Value></Neq>"+"<Neq><FieldRef Name='Status'/><Value
Type='Text'>Cancelled</Value></Neq>"+
"</And></Where>";
I have nearly 6 options in Status field, i have to get the values which Status
is not equal to 'Close', 'Cancelled', 'Fixed', how to do this? Can anyone help
me out, please!
Thanks in advance
spashikantispQuery = newSPQuery();"<OrderBy><FieldRef Name='ID' Ascending='TRUE'
/></OrderBy>"+"<Where><And>" + spQuery = newSPQuery();"<OrderBy><FieldRef
Name='ID' Ascending='TRUE' /></OrderBy>"+"<Where><And>"+

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Error if using &lt;Neq&gt; tag more than 2 times Or get search suggestion and latest updates.




Tagged: