I wanted to update the Name field in a list which contain 'finance' in the department list. I wrote the following code but it updates every item in the Name column whether it contains 'finance' or not.
What am i doing wrong?
SPListItemCollection Items = RiskAssesment.GetItems(new SPQuery()
{
Query = @"<where>
<Eq>
<FiledRef Name 'Department'/>
<Value Type='Text'>Finance </Value>
</Eq>
</Where>"
});
foreach (SPListItem item in Items)
{
item["Name"] = "abcdef";
item.Update();
}
FiledRef should be FieldRef. And you forgot the equal sign, it should be like this:
<FieldRef Name='Department' />
Small edit:
I'm not sure if CAML is case-sensitive, but in case it is: change the opening-where to <Where>
.