locked
CAML query RRS feed

  • Question

  • Hi

    I have the following CAML query:

    <Where>
    <AND>
    <Eq>
    <FieldRef Name='Url' />
    <Value Type='Text'>www.yahoo.com</Value>
    </Eq>
    <Eq>
    <FieldRef Name='Description' />
    <Value Type='Text'>yahoo</Value>
    </Eq>
    </AND>
    </Where>

    when I put set the above string to the query oject and then run the following line: 

    web.["Locations"].GetItems(query);

    I get an exception saying: "The parameter is incorrect".  The strange thing is if I run the query in a CAML builder tool, the query runs fine in the tool; and if I take out the <AND> and one of the equal conditions, the query runs fine in my code.  My code is running off of a WSS 2 site;  so, I'm wondering if there was a change to the CAML syntax from WSS 2 to WSS 3? 

    I would greatly appreciate any pointers.  Thanks in advance.
    Wednesday, December 10, 2008 12:04 AM

Answers

  • Have you tried using And instead? Just recently I had a look at the CAML.xsd provided with WSS 3.0 and the And element is spelled title-cased.
    -- http://blog.mastykarz.nl
    Wednesday, December 10, 2008 7:00 AM
  • Please note that CAML query is case-sensitive. Similar questions have been appearing in the past few days.
    ________________________________________ Gautham S Pai [MCAD]
    Wednesday, December 10, 2008 8:43 AM
  • Yes, it's supposed to be "And" and not "AND".  Thank you everyone for your help
    • Marked as answer by Rachel.lane Wednesday, December 10, 2008 5:29 PM
    • Unmarked as answer by Rachel.lane Wednesday, December 10, 2008 5:30 PM
    • Marked as answer by Rachel.lane Wednesday, December 10, 2008 5:30 PM
    Wednesday, December 10, 2008 5:29 PM

All replies

  • Your CAML query is absolutely correct.

    But i dont know how to retrieve data using this query in WSS 2.0.
    I am working in WSS 3.0 and this is how we retrieve the data -

    SPList objSPList= web.Lists["MyList"];
    objSPList.GetItems(query);


    Wednesday, December 10, 2008 6:58 AM
  • Have you tried using And instead? Just recently I had a look at the CAML.xsd provided with WSS 3.0 and the And element is spelled title-cased.
    -- http://blog.mastykarz.nl
    Wednesday, December 10, 2008 7:00 AM
  • Please note that CAML query is case-sensitive. Similar questions have been appearing in the past few days.
    ________________________________________ Gautham S Pai [MCAD]
    Wednesday, December 10, 2008 8:43 AM
  • Yes, it's supposed to be "And" and not "AND".  Thank you everyone for your help
    • Marked as answer by Rachel.lane Wednesday, December 10, 2008 5:29 PM
    • Unmarked as answer by Rachel.lane Wednesday, December 10, 2008 5:30 PM
    • Marked as answer by Rachel.lane Wednesday, December 10, 2008 5:30 PM
    Wednesday, December 10, 2008 5:29 PM