Connecting to mySQL database using asp.net

So, after some attempts, I realized that I needed a driver for this. I installed the components from the links below. But I still can’t find the SQL references when I try to add them? I am wondering if anyone will find out the reason for this? I just started with asp.net. I found some other questions regarding the connection code, but I can not find those who had problems with the Connector / components component before?

MYSQL Connector http://dev.mysql.com/downloads/connector/net/5.0.html

Microsoft Data Access Components (MDAC) 2.8 http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&displaylang=en

I am using Visual Studio.

+4
source share
2 answers

Right-click the link, then select Add Link. Find and select Mysql.Data.dll .

The DLL should be found in the installation directory of the connector you downloaded.

enter image description here

Finally, in the code:

 using MySql.Data.MySqlClient; 

And, an example connection:

 MySqlConnection connection = new MySqlConnection("Database=database_name;Data Source=server_domain_or_ip;User Id=mysql_user;Password=mysql_password"); connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "select * from mytable"; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { //reader.GetString(0) //reader["column_name"].ToString() } reader.Close(); 
+14
source

You can go to the DLL and add the link.

0
source

Source: https://habr.com/ru/post/1340494/


All Articles