SPList没有更新?(SPList is not updating?)

编程入门 行业动态 更新时间:2024-10-27 16:24:15
SPList没有更新?(SPList is not updating?)

我正在尝试为用户更新UserInformationList。 它正在正确执行SPListItem.Update()但更新未反映在列表中。 我不明白我在哪里做错了。 我在这附上我的代码。

private bool SyncingProcess(SqlDataReader d, SPList UserInfoList) { bool result =false; try { //--> SPListItem UILUser = null; // Build a query. SPQuery query = new SPQuery(); query.Query = string.Concat( "<Where><Eq>","<FieldRef Name='Name'/>", "<Value Type='Text'>" +(d.IsDBNull(accountIDPOS) == false ? d.GetString(accountIDPOS) : "information not found") + "</Value>", "</Eq></Where>"); query.ViewFields = string.Concat("<FieldRef Name='FirstName' />","<FieldRef Name='LastName' />", "<FieldRef Name='Email' />","<FieldRef Name='FullName' />","<FieldRef Name='Title' />", "<FieldRef Name='JobTitle' />"); SPListItemCollection userInfoListitems = UserInfoList.GetItems(query); if (userInfoListitems != null && userInfoListitems.Count > 0) { UILUser = userInfoListitems[0]; SPUser user1 = UILUser.Web.EnsureUser("aspnetsqlmembershipprovider:" + d.GetString(accountIDPOS)); if (UILUser != null) { UILUser["FirstName"] = (d.IsDBNull(FIRSTNAMEPOS) == false ? d.GetString(FIRSTNAMEPOS) : ""); UILUser["LastName"] = (d.IsDBNull(LASTNAMEPOS) == false ? d.GetString(LASTNAMEPOS) : ""); UILUser["Title"] = (d.IsDBNull(FULLNAMEPOS) == false ? d.GetString(FULLNAMEPOS) : ""); UILUser["EMail"] = (d.IsDBNull(EMAIL_ADDRESSPOS) == false? d.GetString(EMAIL_ADDRESSPOS): ""); UILUser["JobTitle"] = (d.IsDBNull(TITLEPOS) == false ? d.GetString(TITLEPOS) : ""); UILUser.Update();; UserInfoList.Update(); } result =true; } else { tw.WriteLine("User not found in the " + UserInfoList.ParentWeb.Title.ToString() + " Site " + (d.IsDBNull(FIRSTNAMEPOS) == false ? d.GetString(FIRSTNAMEPOS) + "; " + d.GetString(accountIDPOS) : "information not found")); tw.Flush(); } } catch (Exception) { result =false; } return result; } }

}

I am trying to update UserInformationList for the user. It is executing SPListItem.Update() properly but update was not reflect in the list. I don't understand where I am doing mistake. I attaching my code here.

private bool SyncingProcess(SqlDataReader d, SPList UserInfoList) { bool result =false; try { //--> SPListItem UILUser = null; // Build a query. SPQuery query = new SPQuery(); query.Query = string.Concat( "<Where><Eq>","<FieldRef Name='Name'/>", "<Value Type='Text'>" +(d.IsDBNull(accountIDPOS) == false ? d.GetString(accountIDPOS) : "information not found") + "</Value>", "</Eq></Where>"); query.ViewFields = string.Concat("<FieldRef Name='FirstName' />","<FieldRef Name='LastName' />", "<FieldRef Name='Email' />","<FieldRef Name='FullName' />","<FieldRef Name='Title' />", "<FieldRef Name='JobTitle' />"); SPListItemCollection userInfoListitems = UserInfoList.GetItems(query); if (userInfoListitems != null && userInfoListitems.Count > 0) { UILUser = userInfoListitems[0]; SPUser user1 = UILUser.Web.EnsureUser("aspnetsqlmembershipprovider:" + d.GetString(accountIDPOS)); if (UILUser != null) { UILUser["FirstName"] = (d.IsDBNull(FIRSTNAMEPOS) == false ? d.GetString(FIRSTNAMEPOS) : ""); UILUser["LastName"] = (d.IsDBNull(LASTNAMEPOS) == false ? d.GetString(LASTNAMEPOS) : ""); UILUser["Title"] = (d.IsDBNull(FULLNAMEPOS) == false ? d.GetString(FULLNAMEPOS) : ""); UILUser["EMail"] = (d.IsDBNull(EMAIL_ADDRESSPOS) == false? d.GetString(EMAIL_ADDRESSPOS): ""); UILUser["JobTitle"] = (d.IsDBNull(TITLEPOS) == false ? d.GetString(TITLEPOS) : ""); UILUser.Update();; UserInfoList.Update(); } result =true; } else { tw.WriteLine("User not found in the " + UserInfoList.ParentWeb.Title.ToString() + " Site " + (d.IsDBNull(FIRSTNAMEPOS) == false ? d.GetString(FIRSTNAMEPOS) + "; " + d.GetString(accountIDPOS) : "information not found")); tw.Flush(); } } catch (Exception) { result =false; } return result; } }

}

最满意答案

您可能想要调用UserInfoList.ParentWeb.Update()

You might want to call UserInfoList.ParentWeb.Update()

更多推荐

本文发布于:2023-08-06 13:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1448470.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SPList   updating

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!