I am trying to check a list for related values but for some reason every item in the list is returned each time. I have seen this issue before and for me its always meant a bad CAML string but I have not been able to figgure out what is wrong.
Table contains two extra fields:
FieldName | Type --------------------------- 'List' | GUID 'URL' | URL
SPWeb web = SPContext.Current.Web; String myID=web.Lists["myList"].ID.ToString(); String myUrl = web.Url; SPQuery MyQuery = new SPQuery(); MyQuery.Query= " <Where> <And> <Contains> <FieldRef Name='List'/> <Value Type='String'>"+myID+"</Value> </Contains> <Eq> <FieldRef Name='URL'/> <Value Type='URL'>"+myUrl+"</Value> </Eq> </And> </Where>"; SPListItemCollection results = web.Lists["sourceList"].GetItems(MyQuery);
I have also tried with in place of and Text in place of String.
- I do know the (string)list.ID. is same format as my GUID Field which is why matching by string should work