Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6159539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:08:59+00:00 2026-05-23T21:08:59+00:00

I am using the createuserwizard to store additional user info into a mysql database,

  • 0

I am using the createuserwizard to store additional user info into a mysql database, apart from the info provided by the asp.net membership provider. I would like to store this info into another table called ‘userprofile’. The user id in ‘userprofile’ is of type int and is a foreign key referencing ‘id’ of ‘my_aspnet_users.

This is my problem:
I can’t seem to get the user id of the newly created user to store in my ‘userprofile’ table. These lines don’t work:

        MembershipUser newUser = Membership.GetUser(RegisterUser.UserName);
        Int32 newUserId = (Int32)newUser.ProviderUserKey;            

These lines are causing the username to be set to the guid value returned by ProviderUserKey, which is so odd! The id column from my_aspnet_users, on the other hand, gets incremented by 1 when the user is created. And nothing gets added to the ‘userprofile’ table.

This is where I inserted the above code:

       protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);

        string continueUrl = RegisterUser.ContinueDestinationPageUrl;
        if (String.IsNullOrEmpty(continueUrl))
        {
            continueUrl = "~/";
        }

        // Retrieve all the values from the registration form to insert into database
        TextBox FirstNameTextBox = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("FirstName");
        TextBox LastNameTextBox = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("LastName");
        TextBox UsernameTextBox = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("UserName");
        TextBox EmailTextBox = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Email");

        // Get the UserId of the just-added user
        MembershipUser newUser = Membership.GetUser(RegisterUser.UserName);
        Int32 newUserId = (Int32)newUser.ProviderUserKey;            

        MySqlConnection DBConn = new MySqlConnection(WebConfigurationManager.ConnectionStrings["LocalMySqlServer"].ConnectionString);
        MySqlCommand DBCmd = new MySqlCommand(); 

        try
        {
            // Add Insert statement to insert into database
            DBCmd = new MySqlCommand(
                "INSERT INTO userprofile(UID, Email, Fname, Lname)" +
                "VALUES (@UID, @Email, @Fname, @Lname)", DBConn);

            // Add database parameters
            DBCmd.Parameters.Add("@UID", MySqlDbType.Int32).Value = newUserId;
            DBCmd.Parameters.Add("@Email", MySqlDbType.VarChar).Value = EmailTextBox.Text;
            DBCmd.Parameters.Add("@Fname", MySqlDbType.VarChar).Value = FirstNameTextBox.Text;
            DBCmd.Parameters.Add("@Lname", MySqlDbType.VarChar).Value = LastNameTextBox.Text;
            DBCmd.ExecuteNonQuery();
        }

        catch(Exception exp){
            Response.Write(exp);
        }

        // Close database connection and dispose database objects
        DBCmd.Dispose();
        DBConn.Close();
        DBConn = null;

        Response.Redirect(continueUrl);

    }

Has anyone worked with mysql and the createuserwizard for additional info?

Any help would be appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:08:59+00:00Added an answer on May 23, 2026 at 9:08 pm

    It turns out there is nothing wrong with the above code. I was messing around with the user id value in another function, which was causing trouble in here!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I am using asp.net's built-in membership provider, then how can I store arbitrary
First time using the ASP.NET CreateUserWizard control and we are aliasing the Username Textbox
I am using ASP.NET membership in a web application. I have the following code
I am using the built-in asp.net membership framework. I created a registration page and
I'm using various ASP.NET controls out of the box such as the CreateUserWizard control,
I had done the registration using ASP.NET CreateUserWizard Control . In here I want
Using ASP.NET MVC there are situations (such as form submission) that may require a
I am using the CreateUserWizard to register a user. The control's built-in logic is
I am using createuserwizard to register the users for the website. When the user
I only want to use CreateUserWizard Control to collect information from the user and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.