0
         string query = <Where> 
                           <And>    
                              <And>       
                                 <And>          
                                      <Eq></Eq>
                                      <Eq></Eq>
                                 </And>
                                   <Geq></Geq>
                                   <Leq></Leq>
                              </And>       
                                <Eq></Eq>
                           </And>
                        </Where>

In SharePoint foundation development, i have used this CAML query to query a SharePoint list. This query contains five conditions. After above query gets executed, it throws an Microsoft.Sharepoint.SPException exception. I tried but couldn't figure it out. Is there any mistake in above CAML query. Any help is appreciated.

Nera
  • 528
  • 2
  • 7
  • 11

3 Answers3

0

Please check your query. The below query I generated with U2U tool

<Where>
      <And>
         <And>
            <And>
               <Eq>

               </Eq>
               <Eq>

               </Eq>
            </And>
            <Eq>

            </Eq>
         </And>
         <Eq>

         </Eq>
      </And>
   </Where>

It should follow this format.

Download link for U2U and reference

http://www.u2u.be/Software

Where can i download the U2U CAML query Builder for Sharepoint 2010?

Pushpendra
  • 1,345
  • 9
  • 16
0

I'm in a hurry, to avoid errors in CAML query, try to build the query using CAML Query Builder.

Hope this helps you.

Karthik Jaganathan
  • 7,848
  • 4
  • 34
  • 51
0

You have 3 child elements under the second And element: And, Geq and Leq. It is not supported. Wrap Geq and Leq elements with an additional And parent element and it will work.

Or, as suggested in other answers, use CAML query builder to generate your queries.

Tim
  • 451
  • 3
  • 5