CAML query returns wrong results?
Posted
by
Abe Miessler
on Stack Overflow
See other posts from Stack Overflow
or by Abe Miessler
Published on 2011-01-12T23:25:58Z
Indexed on
2011/01/13
1:53 UTC
Read the original article
Hit count: 205
I have the following code:
SPQuery oQuery = new SPQuery();
oQuery.Query = @"<Query>
<Where>
<And>
<Eq>
<FieldRef Name='PublishToSM' />
<Value Type='Boolean'>1</Value>
</Eq>
<IsNull>
<FieldRef Name='SMUpdateDate' />
</IsNull>
</And>
</Where>
</Query>";
SPListItemCollection collListItems = list.GetItems(oQuery);
NevCoSocialMedia.NevCoFacebook fb = new NevCoSocialMedia.NevCoFacebook();
foreach (SPListItem oListItem in collListItems)
{
if (oListItem.Fields.ContainsField("PublishToSM") && Convert.ToBoolean(oListItem["PublishToSM"]) == true)
{
.
.
.
My question is why do I need to have the last if
statement? If I don't have this it will throw an error saying that the identifier does not exist when it tries to do oListItem["PublishToSM"]
. This seems impossible since my CAML query is checking that that has an appropriate value...
© Stack Overflow or respective owner