I'm just trying to connect vb.net application to my cpanel web host space's mysql database.
I got some idea from internet and tryied. But It doesn't work for me. If you know about this help me. I think it was great help for others too.
my whole code is this :

Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class Form1
    Dim dr As MySqlDataReader
    Dim con As New MySqlConnection
    Dim da As New MySqlDataAdapter
    Dim ds As New DataSet
    Dim cmd As New MySqlCommand
    Dim query As String
    Public dt As DataTable
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        con.ConnectionString = "server=//194.23.243.112;Port=3306; User ID=xyz; password=#1dFs@#gc53; database=testonline"
         Try
            con.Open()
            MessageBox.Show("Okay")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class

however this say : "Unable to connect to ant specified host"

Hi, are you sure the database system allows remote connections? The default setup for MySQL listens on localhost. Consider also that some hosting services provide access only from a restricted range of IPs, usually their web servers.

web.config file
con.ConnectionString = "server=server ip address;username=xxxxx;password=xxxxxx,database name=xxxxx;

and add mysql dll in ur project

call refernce namespace
using system.mysql.data.mysqlclient

You need to install Connector/Net, which will give you a full ADO.Net provider for MySql you can use. Be warned that this is GPL software, meaning if you distribute it as part of a commercial product you must also distribute your source code. It's an open legal question, but last I heard most web sites are okay with this, because you are not distributing your server code. Desktop apps may have an issue, though.

This article has been dead for over six months. Start a new discussion instead.