Use MySQL database for verification in Asp.net

Source: Internet
Author: User

The following articles mainly describe how to use the MySQL database for verification in Asp.net, and always want to combine Asp.net with the MySQL database, including usage. net provided providers, membership, roles and other login verification, because MsSql is too large, personal use is not necessary.

Google has been on the Internet for a long time and has not found any valuable things. Most of them are reading and writing MySQL Data, and there is still a lot of misleading information on the Internet, through some open-source plug-ins). In fact, MySQL-connector-net, the official MySQL database, supports asp.net authorization as early as 5.1. There are few configuration tutorials on the official website and google, finally, I found detailed configuration instructions on a Turkish website. The details are as follows:

1. Download MySQL Connector. I downloaded 5.2.5 at the address of and vs2008 for some default configurations, saving the trouble of manual configuration.

2. Add ConnectionString to the web. config file of the website.

 
 
  1. <connectionStrings>   
  2. <remove name="LocalMySQLServer"/>   
  3. <add name="LocalMySQLServer" connectionString="server=localhost; 
    user id=root; password=toor; persist security info=true; database=dorknozzle;
    " providerName="MySQL.Data.MySQLClient"/>   
  4. </ connectionStrings> 

3. Copy the MySQL. Data. dll file to the bin folder of the website and add references.

4. In the machine. config c: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727 \ Config \ machine. add autogenerateschema = "true" in config to automatically generate related table structures as follows:

 
 
  1. <membership>   
  2. <providers>   
  3. <add name="MySQLMembershipProvider" autogenerateschema="true" type="MySQL.
    Web.Security.MySQLMembershipProvider, MySQL.Web, Version=5.2.2.0, ... />   
  4. </providers>   
  5. </membership> 

5. Open the Asp.net website management tool project> ASP. NET configuration), select "select different providers (advanced) for each function" on the "providers" page, and then select MySQLMembershipProvider in "membership providers, in "role provider", select MySQLRoleProvider.

6. enjoy the fun of Asp.net and MySQL databases!

The following error occurs during the test. The error message in English version is no longer displayed. The error message in Chinese version is not saved ):

There is a problem with your selected data store. this can be caused by an invalid server name or credentials, or by insufficient permission. it can also be caused by the role manager feature not being enabled. click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to initialize provider. missing or incorrect schema. (c: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727 \ Config \ machine. config line 145)

The above content is an introduction to the use of MySQL database for verification in Asp.net. I hope you will have some gains.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.