I am trying to get a specific item from sharepoint list, representing the username of the current logged in user. The list has a column called UserName, which has values like: i:0#.f|sql_membership|Jacky
I am building a CAML query in C#, to get the row where current logged in user = that column. My code looks like this:
SPUser user = web.CurrentUser; string userName = user.LoginName; query.Query = "<View><Query><Where><Eq><Field Name= 'UserName'/><Value Type='Text'>" + userName + "</Value></Eq></Where></View></Query>"; SPListItemCollection items = list.GetItems(query); SPListItem item = items;
The problem, is that it brings the first row with ID =1, which has the value of: i:0#.f|sql_membership|Edward while it should bring: i:0#.f|sql_membership|Jacky according to the value the userName variable which has my username
How do I solve this?