首页 > 代码库 > net6:创建Membership对象数据源的代码

net6:创建Membership对象数据源的代码

原文发布时间为:2008-07-30 —— 来源于本人的百度文章 [由搬家工具导入]

添加了一个db的类作为了对象数据源:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// db 的摘要说明
/// </summary>
public class db
{
public db()
{
   //
   // TODO: 在此处添加构造函数逻辑
   //
}
    public static MembershipUserCollection GetAllUsers()
    {
        int a = Membership.GetAllUsers().Count;
        return Membership.GetAllUsers(0, 5, out a);
    }

    public static MembershipUser GetUser()
    {
        return Membership.GetUser();
    }

    public static MembershipUser GetUser(string UserName)
    {
        return Membership.GetUser(UserName);
    }

    public static void Update(string Comment, string Email, bool IsApproved)
    {
        MembershipUser mu = Membership.GetUser();
        mu.Comment = Comment;
        mu.Email = Email;
        Membership.UpdateUser(mu);
    }
    public static void UpdateAll(string UserName,bool IsLockedOut,string Comment, string Email)
    {
        MembershipUser mu = Membership.GetUser(UserName);
        mu.Comment = Comment;
        mu.Email = Email;
        if (IsLockedOut = false)
        {
            mu.UnlockUser();
        }
        Membership.UpdateUser(mu);
    }
    public static void Delete(string UserName)
    {
        Membership.DeleteUser(UserName);
    }

}

net6:创建Membership对象数据源的代码