簡體   English   中英

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;
    }
}

}

您可能要調用UserInfoList.ParentWeb.Update()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM