I want to create user dynamically. I used

Membership.CreateUser(smemno.Text.ToString(), spwd.Text.ToString(),semail.Text.ToString(),ssecquestion.SelectedItem.Text.ToString(),sans.Text.ToString(),true);

but error occur : "No overload for method 'CreateUser' takes '6' arguments"

Should I create new method named CreateUser(), if "yes" then what is code for that and what it return...
please help me.

You are missing **MemberShipCreateStatus** argument.

System.Web.Security.MembershipCreateStatus mcs;
System.Web.Security.Membership.CreateUser("username", "password", "username@email.com", "passwordQuestion", "passwordAnswer", true, out mcs);

        switch (mcs)
        {
            case System.Web.Security.MembershipCreateStatus.Success:
                break;
            case System.Web.Security.MembershipCreateStatus.DuplicateEmail:
                break;
            case System.Web.Security.MembershipCreateStatus.DuplicateUserName:
                break;
        }

hope helps u

private string GetErrorMessage(MembershipCreateStatus status)
        {
            switch (status)
            {
                case MembershipCreateStatus.DuplicateEmail:
                    return "right Message";
                case MembershipCreateStatus.DuplicateUserName:
                    return "right Message";
                case MembershipCreateStatus.InvalidAnswer:
                    return "right Message";
                case MembershipCreateStatus.InvalidEmail:
                    return "right Message";
                case MembershipCreateStatus.InvalidPassword:
                    return "right Message";
                case MembershipCreateStatus.InvalidQuestion:
                    return "right Message";
                case MembershipCreateStatus.ProviderError:
                    return "right Message";
                case MembershipCreateStatus.UserRejected:
                    return "right Message";
                default:
                    return "";
            }
        }

MembershipCreateStatus st;
MembershipUser NewUser = Membership.CreateUser(txtUserName.Text, txtPassword.Text, txtEmail.Text, txtSecurityQuestion.Text, txtsecurityAnswer.Text, false, out st);
                        if (NewUser == null)
                        {
                            lblError.Visible = true;
                            lblError.Text = GetErrorMessage(st);
                            return;
                        }

Method also u pass that much parameters... then u wont get error..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.