I am trying to get customers with a matching name from a SharePoint list
I tried with:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Query><Where><Lt><FieldRef Name=\"CustomerName\"/><Value Type=\"Text\">" + customerName + "</Value></Lt></Where></Query>");
XmlNode listQuery = doc.SelectSingleNode("//Query");
XmlNode n = sharePoint.listsObj.GetListItems(listName, null, listQuery, null, null, null, null);
nsmgr = new XmlNamespaceManager(n.OwnerDocument.NameTable);
nsmgr.AddNamespace("z", "#RowsetSchema");
nsmgr.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
XmlNodeList itemNodeList = n.SelectNodes("rs:data/z:row", nsmgr);
But in itemNodeList I get a customer with a name that is not similar at all to the parameter (customerName) I use in the query.
If I don’t pass on the query I get all customers from the list.
Any ideas?
Thanks in advance.
If you want to get names that match exactly then use the Eq tag
For example from
the following
would return
If you want to return names that contain the string then use the Contains tag
would return
Have a look at the U2U CAML Builder
http://www.u2u.net/res/Tools/CamlQueryBuilder.aspx