Today we will see a simple example of How to connect MySQL and VB.NET 2010. For this, follow the steps:

1. First create database in MySQL.

Then create table

customer table

2. After creating database, start visual studio 2010 and click on the new project.

tutorail 1

3. After creating new project, click on the Project which is on the menu and click on the Add Reference and select .Net and search MySql.Data. Select the MySql.Data and click on OK.

add reference

4. After that double click on the form and click above on the public class because we have to import some MySQL drivers like mysql.data, mysql.data.mysqlclient.

connection code

5. With the help of these drivers we can use mysql component classes that make up the data provider.

6. Instead of writing connection code in the form, you can also write on the Module.

add module

7. Because in the module once you create connection, you can call that function everywhere and if you make any changes in the connection code, you have don’t need edit code in each and every form. Only you have open Module and edit the code save it.

8. Here is the example to connect MySQL with VB.NET

9. Connection function calls wherever you want.

Example –

form 1 testing