Creating MySQL Connection using VB.Net

0
579

MySQL is the common Database System used today and mostly compatible in any different programming languages. This tutorial entitled “Creating MySQL Connection using VB.Net” will teach you how to create a MySQL connection through the Visual Basic.Net language.

Step1


Open your project and in the “Project Menu”, select “Add Reference”.

Step2


When the “Add reference” box appear, find and select “MySQL.Data” in the “.Net” tab and Click Ok. The MySql.Data reference is now added to your project.

Step3


Back to your “Project” menu and select “Add Module”. The codes will be inserted in your new created module.

Step4


Add new item dialog box appeared. Input the name of your module and click add button. In my case I used “dbconfig”.

Step5


Add the following codes inside your new created module.

Import libraries

  1. Imports MySql.Data.MySqlClient

Creating MySQL Connection

  1. Public conn As New MySqlConnection("host=localhost;user=root;password=;port=3306;")

Conn – the name of your connection, we use this connection in your CRUDS function.

Host– the host name of your MySQL Server

User– the user name of your MySQL Server

Password – The password of your MySQL Server

Port – The port of your MySQL Server

Overall View of Codes

  1. Imports MySql.Data.MySqlClient
  2. Module dbconfig
  3. Public conn As New MySqlConnection("host=localhost;user=root;password=;port=3306;")
  4. End Module

REMEMBER: This is the first method if you are working with C.R.U.D.S (Create, Read, Update, Delete, Search) application. This is also tested in Visual Studio 2008 and MySQL Server 5.1.

 

Next Topic: How to Save Data Using VB.Net and MySQL Database

Advanced Topic:

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here