How to Connect MySQL To Visual Studio 2019 | Complete Guide

2
267

How to Connect MySQL To Visual Studio 2019

This is a Complete Guide on How to Connect MySQL To Visual Studio 2019 where you will learn how to manipulate MySQL Database using different VS versions.

In this tutorial on how to connect MySQL Database to visual studio .NET you will be introduced to the best practices on how to manipulate MySQL data using VB.NET.

Before we begin, watch here first the video on how to connect access database to vb.net application to get some ideas on the foregoing paragraph.

Anyway if you have not yet installed visual studio 2013, 2015, 2017 or 2019 version, you can download the visual studio here.

How to Connect MySQL to Visual Studio 2019

  1. Open Visual Studio

    You can you use visual studio 2015, 2017 or 2019 for this tutorial.

  2. Create a VB.Net Project.

    File New Project->Under Templates Select Visual Basic or Visual C#. as shown in the image below.
    create vb.net with visual studio 2019

  3. Add mysq.data.dll Reference

    Right Click Solution Explorer ->Click Add -> Select Reference.
    add mysql.data.dll reference visual studio 2019

  4. Select MySQL.data.dll from your recent Tab.

    On the reference Manager, Click Browse / Recent the Select the MySql.data.dll.
    See the complete guide here on how to add mysql.data.dll in visual studio.
    reference manager

  5. Add Import above Public Class.

    imports mysql.data.mysqlclient to visual studio 2019

  6. Setup Connection String

    Under public class Form1, Add the following declaration and Connectionstring.
    setup connection string in visual studio 2019

  7. Test the connection String.

    test Connection String visual studio

  8. Run your Project.

    Press F5 or simply click the Start Debugging.
    database connected

VB.Net Code to Connect MySQL to Visual Studio.

Load MySQL record in Visual Studio 2019

In this section, we are going to load a record from MySQL Database in VB.Net Application using Visual Studio 2019.

Step by step instructions on how to Load MySQL Record in VB.Net

Step 1: Create a table in the MySQL database. To do this, execute the SQL code below.

Step 2: Add 1 button to Form1 and 1 Datagridview1. Then Arrange it similar in the image below.

Step 3: Then Double click the “Load Record” Button and add the following code.

Step 5: Press F5 to test the project. When you execute the program and click the Load record button. You will see a result that looks as shown below.

Here’s a sample Code on how to Insert Record in MySQL using VB.Net using Visual Studio 2019.

You check here on how to add multiple records in vb.net to MySQL Database.

Updating of Records

Here’s a sample Code on how to Update MySQL Database in VB.Net using Visual Studio 2019.

Deleting of Records from MySQL Database

Here’s a sample Code on how to Delete Record in MySQL using VB.Net using Visual Studio 2019.

After you complete this tutorial, you will be able to develop your own personalized vb.net projects.

You can watch here the complete video tutorial on how to master VB.Net with MySQL Database.

Summary

In summary, we have discussed here how to connect MySQL to visual studio 2019. Next, we also learn how to load the Mysql record from the database using VB.Net. Then, we have given also a code on how to Insert, Update and Delete Record from MySQL using VB.Net 2019.

Inquiries

If you have any questions or suggestions about this tutorial on how to connect MySQL to Visual Studio 2019 or using different versions, please leave a comment below.

2 COMMENTS

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.