CAML query is really very helpful while working with SharePoint Server Object Model to query data from SharePoint list and libraries.But while working with Server Object Model I was facing one issue ,that my query was not working properly, as i was not getting expected result.I also debug the code and their was no error while debugging in query.Below is the SPQuery which was not working.
getSubHeaderQuery.Query = "<Query><Where> <Eq> <FieldRef Name='MainHeader'/> <ValueType='Lookup'>" + MainHeader + "</Value> </Eq></Where></Query>";
Solution:
After spending some time and struggling with above query , i got soloution and finally my query starts working.Solution is very simple ,just remove the <Query> </Query> tag from the query string and it will work fine .
SPQuery getSubHeaderQuery = new SPQuery();
getSubHeaderQuery.Query = "<Where> <Eq> <FieldRef Name='MainHeader'/> <Value Type='Lookup'>" + MainHeader + "</Value> </Eq></Where>";
No comments:
Post a Comment