ASP.NET development actual combat - (h) MySQL ASP.NET MVC with a database of

  Before My Blog describes how to use ADO.NET to access SQL Server data acquisition. This chapter describes how to use the My SQL for data management.
  Before using My SQL My SQL database and the need to ensure Connector / Net development environment installed, which is written in C # ADO.NET data provider, in other words whether using SQL Server or My SQL, ASP.NET all is accessible through ADO.NET, database operations, their only difference is the data provider, the connection My SQL type System.Data.dll still need to use the following article before described:

 

  The only difference is My SQL ADO.NET data is provided to install Connector / Net.

  This article describes how to use the following two points My SQL database in ASP.NET:

  ● My SQL and install Connector / NET
  ● Create a new project for the My SQL Warehousing

My SQL and install Connector / NET

  Connector / NET Download: https://dev.mysql.com/downloads/windows/installer/
  MySQL Download (directly choose whether to install when you install Connector / NET): https://dev.mysql.com/downloads/ mysql /

  Add data tables with the data after the completion of:

  

 

Create a new storage project for the My SQL

  To create a new project because let SQL Server and My SQL coexist, the two will not affect each other, to the latter can be switched purpose of the database by a simple modification.

  1. Create a new Class Library project BlogRepository.MySQL, and references Mysql.Data (Note: Mysql.Data need to install the Connector / NET):

  

  

  2. The use of SQL execution to achieve a BlogRepository:

  

  

  

  Comparison with the code SQL Server, only the name of the object, and differences in SQL connection string.

  3. Change the logical layer reference, use BlogRepository.MySQL, and modify the incorrect namespace:

  

  

  4. Run the program:

  

   

summary

  This chapter describes how to use ASP.NET, MySQL database, it is used with SQL Server is basically the same, only you need to install the components connected to My SQL required. Another issue to note is that there are now BlogRepository and BlogRepository.MySQL two storage libraries throughout the solution, respectively, were for SQL Server and My SQL, but only a logical layer, which means that each time you change the database business logic libraries not only to replace the references, but also to modify the code. This is a typical implementation dependent and not dependent on the abstract question. This problem will be introduced in subsequent solutions.

 

reference:

  https://dev.mysql.com/doc/connector-net/en/connector-net-programming-connecting.html

 

Welcome to add a personal Micro Signal: Like if thoughts.

I welcome the attention of the public numbers, not only recommend the latest blog for you, there are more surprises waiting for you and resources! Learn together and common progress!

 

Guess you like

Origin www.cnblogs.com/cool2feel/p/11544524.html