Vb.net Connect to mySql server remotely

0 Kevin Ongili · April 20, 2015
Hi everyone,
I have developed a number of desktop applications using vb.net now i want to provide an option of acquiring license online.
I want the program to access an online mysql server database and pick the registration key from one of the tables,

the question is what is the connection string for connecting to that mysql server.

thank you in advance

Post a Reply


Oldest  Newest  Rating
0 Nathan Chambers · May 4, 2015
You have problem figured it out by now, but I'll post a quick example anyways for retrieving from a mysql db.

Imports MySql.Data.MySqlClient

Public Class Form1
    Public connData As String = "Server=xHOSTx; User Id=xUSERx; Password=xPASSx; Database=xDBx"
    Public conn As MySqlConnection = New MySqlConnection(connData)
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim data = TextBox1.Text
        Dim startSQL As String = "SELECT * FROM messages ORDER BY id ASC"
        Dim sql As String = "INSERT INTO `messages`(`text`) VALUES ('" & data & "')"
            Dim adapter As MySqlDataAdapter = New MySqlDataAdapter(sql, conn)
            Dim ds As DataSet = New DataSet()
            adapter.Fill(ds, "Messages")
            Dim rowVals(1) As Object
            rowVals(0) = "1"
            rowVals(1) = data.ToString
            adapter.InsertCommand = New MySqlCommand(sql, conn)
            adapter.Fill(ds, "Messages")
        Catch ex As Exception

        End Try
    End Sub
End Class
  • 1

Visual Basic


One of the first products to provide a graphical environment and a paint metaphor for developing user interfaces.

Bucky Roberts Administrator