Linking MySql to your VB.Net project!

in #vb7 years ago

Hello everyone,
Today I am going to share with you how to link your VB.Net project to your MYSQL database.

First you will want to start with getting the MYSQL.dll from https://dev.mysql.com/downloads/connector/net/1.0.html

download.jpg

After the install is complete you will want to put that .dll file in your working project directory.

Next you will enter your VB.Net project and go to 'Project' > 'Add Reference...'

In this window you will choose from the side options, 'COM' then at the bottom of that screen click 'Browse...'

Search for the .dll file that you placed in your projects working directory, add it and press 'OK' on your Reference Manager page.

YOU HAVE NOW ADDED THE MYSQL.DLL TO YOUR VB.NET PROJECT...

Next you are going to open a new windows form.

In the new windows form, go to the code of the form. ABOVE the 'Public Class ProjectName' area, type in

Imports MySql.Data
Imports MySql.Data.MySqlClient

UNDER the 'Public Class ProjectName' area type in,

'This will create a new Mysql connection
Dim MysqlConn As MySqlConnection

'This will create a new MysqlCommand
Dim COMMAND As MySqlCommand

'This is going to link you database to your project. Fill the information in that matches your database information
Dim oDatabaseConnection = "server=localhost;uid=YOURID;pwd=YOURPASSWORD;database=DATABASENAME;Convert Zero Datetime=True;Allow Zero Datetime=No;pooling=false;default command timeout=3600;"

CONGRATS!! You have now connected your VB.Net project to your MYSQL Database.
You will need to use the code listed in each form that you want to pull database information into.
I will leave a full example of the way your code should look below....

''START CODE''

Imports MySql.Data
Imports MySql.Data.MySqlClient

Public Class Customer_Config

Dim MysqlConn As MySqlConnection
Dim COMMAND As MySqlCommand
Dim oDatabaseConnection = "server=localhost;uid=root;pwd=B3ll2424;database=ttpos;Convert Zero Datetime=True;Allow Zero Datetime=No;pooling=false;default command timeout=3600;"

End Class

''END CODE''

ENJOY!

Sort:  

Congratulations @croftj0827! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got a First Reply

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Coin Marketplace

STEEM 0.30
TRX 0.11
JST 0.031
BTC 69345.27
ETH 3816.44
USDT 1.00
SBD 3.67