Home > Database > Mysql Tutorial > body text

How to connect to mysql database in C#?

黄舟
Release: 2019-02-22 16:45:16
Original
20105 people have browsed it

Many people who use C# believe that it is a headache to connect to the MySQL database. So how does C# connect to MySQL? Next, please follow the editor

Recommended related mysql video tutorials: "mysql tutorial"

1. First download mysql.data.dll# from the Internet

How to connect to mysql database in C#?

##2. Create a new mysql database, such as the test here, and then create a table, such as the Users table in the example

How to connect to mysql database in C#?

3. Enter some data in the table

How to connect to mysql database in C#?

Connect and test

1. Create a windows application form

How to connect to mysql database in C#?

2. Add a reference and introduce the downloaded mysql.data.dll

How to connect to mysql database in C#?

3. Add a class named MySQLConn.cs

How to connect to mysql database in C#?

4. Write in the class Enter the code as follows, where the MySqlCon in front is the connection string. Note: Please modify the user name and password of the database accordingly

How to connect to mysql database in C#?

## 5. Add a datagridview control in the form application and set it to be docked in the parent container, as shown in the figure

How to connect to mysql database in C#?## 6. Double-click the title of the form, and then write the code in the load event as shown

How to connect to mysql database in C#?7. Save After running the program, the result is as shown in the figure, the connection test is successful

How to connect to mysql database in C#?##

The above is the detailed content of How to connect to mysql database in C#?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template