Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

CAML QUERIES?

  Asked By: Shauna    Date: Aug 05    Category: Sharepoint    Views: 1270

Anyone able to determine what is wrong with this caml query?

Temp User Assigned Product Access has 5 rows in it. The variable
UPFID gets the correct value as I have dumped the caml string out to
screen and verified it is good. The code should set count to 2 or 3
depending on the value of UPFID. Everytime I run it, count gets 5.
I dont know why it is not applying the where clause?

Any ideas?

int count = 0;
// build the caml string to hit the temp list
StringBuilder TempUserAccessCAML = new StringBuilder();
TempUserAccessCAML.Append("<Query>");
TempUserAccessCAML.Append("<Where>");
TempUserAccessCAML.Append("<Eq>");
TempUserAccessCAML.Append("<FieldRef Name='UPF_x0020_ID'/>");
TempUserAccessCAML.Append("<Value Type='Text'>");
TempUserAccessCAML.Append(UPFID);
TempUserAccessCAML.Append("</Value>");
TempUserAccessCAML.Append("</Eq>");
TempUserAccessCAML.Append("</Where>");
TempUserAccessCAML.Append("</Query>");
SPView view = web.Lists["Temp User Assigned Product Access"].Views
["Search"];

view.Query = TempUserAccessCAML.ToString();
view.Update();

SPListItemCollection collListItems = tempUserList.GetItems(view);

foreach (SPListItem oListItem in collListItems)
{
count++;
}

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Kelvin Mckinney     Answered On: Aug 05

Have you tried the u2u caml  builder at
http://www.u2u.info/SharePoint/U2U%20Community%20Tools/Forms/AllItems.as
px?

 
Answer #2    Answered By: Gaurav Ghosh     Answered On: Aug 05

Yes that was what it was built with.

it works fine when i use the tool to test it, but does not seem to
use the where clause. i am new to this, so i think i am calling it
wrong, as the same thing happens on any list/caml i use.

 
Didn't find what you were looking for? Find more on CAML QUERIES? Or get search suggestion and latest updates.




Tagged: