VB.NET : Setup & Connecting to Remote MySQL Server

VB.NET Tutorial : How to create connection to Remote MySQL Database Server using TCP/IP Client and Server, How to Set up a remote MySQL database connection.

Connection to Remote MySQL Database - How to create a connection from a client Pc to a server database that in one Network? The database server is at and the port number is 3306, Pc client have an ip, so the client and the server is at one Networking Area.

Please read :
  1. Multi Client Server Chat Application TCP/IP Client/Server MultiThreaded
  2. Client Server Chat Application TCP/IP Client/Server for One Client

How to Enable Remote Access To MySQL Database Server?

To can anyone to remote server database, we must setting up database server and the server (xampp) that can romoted by any client,

1. Setting Server Database

at your server, open following this URL : http://localhost:8080/phpmyadmin

Connecting to Remote MySQL Server

Click on your Database > Privileges > and Add user account > OK

Connecting to Remote MySQL Server

2. Setting Xampp Server

at the server PC, open your Xampp Control Panel > Config (Apache) > httpd.conf

Connecting to Remote MySQL Server
Open your httpd.conf using notepad or other text editor, find this line "LoadModule vhost_alias_module modules/mod_vhost_alias.so", then remove the "#" characters and save it.

Open your httpd-xampp.conf.

Connecting to Remote MySQL Server

At the last line, add this following command :
        AllowOverride AuthConfig
	Allow from all
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
Allow from all is using to allow all client connect with our server.

Create Connection to Remote MySQL Server

Open your visual studio and we will create new project "ConnectionTCP", and at the form1.vb add one comboBox, button and one label, just design it look like this

Connecting to Remote MySQL Server

Module Connection (moduleConnection.vb)

Imports MySql.Data.MySqlClient ' we will make connection using ADO.NET
Module ModuleConnection
    Public conn As MySqlConnection ' declare our connection
    Sub openConnection()
        Dim server As String = "" ' our server database
        Dim userID As String = "root" ' Server userid
        Dim password As String = "rahasia" ' server password
        'Dim databases As String = "" 'server database, i have a database, but dor this project we will
        ' not use the database

            Dim query As String = "Server=" & server & "; user id=" & userID & "; password=" & password & "; Convert Zero Datetime=True"
            conn = New MySqlConnection(query)
            If conn.State = ConnectionState.Closed Then
                conn.Open() ' open our connection
                MsgBox("Connection Success !")
            End If
        Catch ex As Exception
            MsgBox("connection filed !")
        End Try
    End Sub
End Module

Source Code Connection TCP (Form1.vb)

Imports MySql.Data.MySqlClient
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            openConnection() ' open our connection
            ' query to show all database from our server
            Dim cmd As String = "SELECT DISTINCT TABLE_SCHEMA FROM information_schema.TABLES"
            Dim da As MySqlDataAdapter = New MySqlDataAdapter(cmd, conn)
            Dim dt As New DataTable ' we will use datatabel

            ' enabling the list of database in the combobox
            ComboBox1.Enabled = True
            ComboBox1.Items.Add("== Select LIST Database ==")

            Dim i As Integer = 0
            While i < dt.Rows.Count
                ' add database list into combobox
                i = i + 1
            End While
            ComboBox1.SelectedIndex = 0
        Catch ex As Exception
            MsgBox("Failed to connect with database server")
        End Try
    End Sub
End Class

Informations :

You can create CRUD Operations using Remote MySQL Database above, just configuration your server database and create connection to your CRUD Project, see crud Project here :
  1. VB.NET SQLite Tutorials : CRUD (add,update,delete) Operations ADO.NET
  2. GridView CRUD Operations in VB.NET using ADO.NET and MySQL Database
  3. CRUD (Create,Read,Update,Delete) Operation Ms Access Database OleDB Connection
  4. VB.NET (Create,Read,Update,Delete) Database SQL Server

Video Tutorial Connecting to Remote MySQL Server

Download Full Source code here
see you next lessons.


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^

Follow by E-Mail


ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
KODE AJAIB: VB.NET : Setup & Connecting to Remote MySQL Server
VB.NET : Setup & Connecting to Remote MySQL Server
VB.NET Tutorial : How to create connection to Remote MySQL Database Server using TCP/IP Client and Server, How to Set up a remote MySQL database connection.
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy