Problem in SharePoint Object model when accessing the sharepoint list items?

Posted by JanardhanReddy on Stack Overflow See other posts from Stack Overflow or by JanardhanReddy
Published on 2010-04-15T10:51:49Z Indexed on 2010/04/15 10:53 UTC
Read the original article Hit count: 288

Filed under:
|
|

just i wrote

using (SPSite site = SPContext.Current.Site) { using (SPWeb web = site.OpenWeb()) { //SPList lst = web.Lists["ManagerInfo"]; SPList lst = web.Lists[strlist];

                      SPQuery getUserNameQuery = new SPQuery();
                      // getUserNameQuery.Query = "<Where><And><Eq><FieldRef Name=\"Region\" /><Value Type=\"Text\">" + strRegion + "</Value></Eq><And><Eq><FieldRef Name=\"PM_x0020_First_x0020_Name\" /><Value Type=\"Text\">" + pmFName + "</Value></Eq><Eq><FieldRef Name=\"PM_x0020_Last_x0020_Name\" /><Value Type=\"Text\">" + pmLname + "</Value></Eq></And></And></Where>";
                       // getUserNameQuery.Query = "<Where><And><Eq><FieldRef Name=\"PM_x0020_First_x0020_Name\" /><Value Type=\"Text\">" + pmFName + "</Value></Eq><Eq><FieldRef Name=\"PM_x0020_Last_x0020_Name\" /><Value Type=\"Text\">" + pmLname + "</Value></Eq></And></Where>";

                       getUserNameQuery.Query = "<Where><Eq><FieldRef Name=\"PM_x0020_Name\" /><Value Type=\"Text\">" + loginName  + "</Value></Eq></Where>";

                      SPListItemCollection items = lst.GetItems(getUserNameQuery);
                      foreach (SPListItem item in items)
                      {
                          managerFName = item["Manager Name"].ToString();
                          strAccounting = item["Accounting"].ToString();

                          managerFName = managerFName.Replace(".", " ");
                          strAccounting = strAccounting.Replace(".", " ");
                          // isFound = true;
                          XPathNavigator managerName = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:txtManagerName", NamespaceManager);
                          managerName.SetValue(managerFName);
                          XPathNavigator accountingName = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:txtAccountingName", NamespaceManager);
                          accountingName.SetValue(strAccounting);
                      }

} }

i used this code in infopath this infopath is using by all users.os when the current login user have no permissions to the list it showing error.when the current login user have full Permission it is working. So Please advise me what can i do inorder to work them for all users.

© Stack Overflow or respective owner

Related posts about sharepoint

Related posts about object