删除MemberShip系统中的用户

时间:2011-10-26 14:33:38

标签: asp.net-membership

我使用三个表作为我的程序的一部分: 1- aspnet_membership(表的字段是asp.net成员资格) 2-aspnet_user(表的字段在asp.net成员中) 3-TBL_INFO(Filds:INFO_ID,INFO_USERNAME,INFO_ADDRESS,INFO_TELL)

所以,当我想在Gridview中显示必填字段时,一切正常,我没有任何问题。

SELECT的存储过程:

CREATE PROCEDURE STR_SELECT_USERS_ADMIN

AS

SELECT     aspnet_Users.UserId, aspnet_Users.UserName, aspnet_Membership.CreateDate, TB_INFO.INFO_ADDRESS, TB_INFO.INFO_TELL, aspnet_Membership.Email, 
                      aspnet_Membership.LastLoginDate
FROM         aspnet_Membership INNER JOIN
                      aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId INNER JOIN
                      TB_INFO ON aspnet_Users.UserName = TB_INFO.INFO_USERNAME

但是当我决定删除用户时,我不能:

删除的存储过程:

ALTER PROCEDURE STR_DELETE_USER
(
@UserId UNIQUEIDENTIFIER

)
AS

DELETE FROM aspnet_Users
WHERE     (UserId = @UserId)

我在GridView中删除程序的代码如下:

protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
        {
            string strUserName = GridView1.Rows[GridView1.SelectedIndex].Cells[0].Text;

            if (Membership.DeleteUser(strUserName, true) == true)
            {
                //GridView1.DataBind();
                lblResult.Text = "Delete Successfully";
            }

            else
            {
                lblResult.Text = "Delete Faild";
            }
            GridView1.DataBind();
        }

和我要删除记录时的错误创建如下:

Server Error in '/' Application.
--------------------------------------------------------------------------------

The parameter 'username' must not be empty.
Parameter name: username 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: The parameter 'username' must not be empty.
Parameter name: username

Source Error: 


Line 26:             string strUserName = GridView1.Rows[GridView1.SelectedIndex].Cells[0].Text;
Line 27: 
Line 28:             if (Membership.DeleteUser(strUserName, true) == true)
Line 29:             {
Line 30:                 //GridView1.DataBind();

谢谢你的时间。非常感谢你

0 个答案:

没有答案