You have written CAML query with where clause using U2U CAML query builder and it's not returning results as expected.
For exmple below is query generated from query builder , this is correct syntax and you are using it with object model :
For exmple below is query generated from query builder , this is correct syntax and you are using it with object model :
SPQuery query = new SPQuery();
query .Query = "<Query>
<Where>
<Eq>
<FieldRef Name='ItemNumber' LookupId = 'TRUE' />
<Value Type='Lookup'>95< /Value>
</Eq>
</Where>
</Query> ";
<Where>
<Eq>
<FieldRef Name='ItemNumber' LookupId = 'TRUE' />
<Value Type='Lookup'>95< /Value>
</Eq>
</Where>
</Query> ";
though this query runs fine in U2U it will not return same result in object model.
Solution : Remove <Query> .....</Query> tags when you want to use this query in code as shown below.
SPQuery query = new SPQuery();
query .Query ="<Where>
<Eq>
<FieldRef Name='ItemNumber' LookupId = 'TRUE' />
<Value Type='Lookup'>95< /Value>
</Eq>
</Where> ";
<Eq>
<FieldRef Name='ItemNumber' LookupId = 'TRUE' />
<Value Type='Lookup'>95< /Value>
</Eq>
</Where> ";
No comments:
Post a Comment