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 6787075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:19:21+00:00 2026-05-26T17:19:21+00:00

This is my first attempt at doing roles for asp.net, what I have is

  • 0

This is my first attempt at doing roles for asp.net, what I have is a mySQL backend, and I want to add a bunch of roles to a user. The code i’m using below, i keep getting the error Unable to connect to SQL Server database. I’m assuming this is because the default provider refers to SQL, but i’m not able to figure out how to switch it so I can add multiple roles to a user. Thanks for the help!

using (MySqlConnection cn2 = new MySqlConnection("Server=localhost;Database=users; User=root;Password=PASSWORD;"))
            {
                cn2.Open();
                MySqlCommand cmd2 = new MySqlCommand(storedProcedureName2, cn);
                cmd2.CommandType = CommandType.StoredProcedure;
                cmd2.Parameters.Add("@usernameID", userID);
                MySqlDataReader dr2 = cmd2.ExecuteReader();
                while (dr2.Read())
                {
                    string roleName = dr2["role"].ToString();
                    Roles.AddUserToRole(userID, roleName);
                }


            }
  • 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-26T17:19:21+00:00Added an answer on May 26, 2026 at 5:19 pm

    You can configure the ASP.NET Membership and roles in the web.config file. Something like this would set your default provider to a MySQL backend:

    <membership defaultProvider="MySqlMembershipProvider">
    <providers>
    <clear />
    <add name="MySqlMembershipProvider" type="MySql.Web.Security.MySqlMembershipProvider,M ySql.Web,Version=6.3.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" autogenerateschema="true" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requireQuestionAndAnswer="false" requireUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="0" passwordStrengthRegularExpression="" applicationName="/" />
    </providers>
    </membership>
    <profile defaultProvider="MySqlProfileProvider">
    <providers>
    <clear/>
    <add name="MySqlProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.3.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" conectionStringName="LocalMySqlServer" applicationName="/"/>
    </providers>
    </profile>
    <roleManager enabled="true" defaultProvider="MySqlRoleProvider">
    <providers>
    <clear/>
    <add connectionStringName="LocalMySqlServer" applicationName="/" name="MySqlRoleProvider"
    type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.3.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </providers>
    </roleManager>
    <trust level="Full"/>
    <machineKey validationKey="AutoGenerate" validation="SHA1"/>
    

    EDIT: I added the connectionStrings section below:

        <connectionStrings>
        <remove name="LocalMySqlServer"/>
        <add name="LocalMySqlServer" connectionString="Server=localhost;Database=users; User=root;Password=PASSWORD;" providerName="MySql.Data.MySqlClient"/>
        </connectionStrings>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so this is my first attempt at doing anything with JSON. I have
This is my first attempt to build an ASP.NET server control. Writing the control
This is my first attempt to read an Excel 2007 file via ADO.net, and
This is my first attempt to inline Java code in Perl. We cannot use
I have the following code. The first attempt at binding to click event does
this if my first attempt at using streaming for WCF, and I am struggling
Because this is my first attempt at an extension method that seems quite useful
This is pretty strange (admitedly, this is my first attempt with python / sqlite),
I'm writing an application using DDD techniques. This is my first attempt at a
First attempt to use this cool site - after searching for 2 hours: So

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.