Now the following steps will show how to connect to a MySQL database using C#.
Step 1
Open MySQL Admin page and create a new database.
Step 2
After creating the new database, create a new table.
Step 3
After creating the new table, open Visual Studio and click on New Project and name the project. It will open the new project, then click on Solution Explorer (F4), right click on “Reference” to add a new reference into the project. Reference those two .dll files to the project (MySql.dll (Win apps), MySql.web.dll (Web apps)).
Step 4
Add namespace to the project.
Step 5
Create a MySQL connection string.
Step 6
The following code will insert the data into MySQL table.
Step 7
The following function will load the data from the table and bind it into a GridView.
Step 8
The final result is shown on the window form: