I am trying to connect mysql database that is on Ubuntu through a vb.net code:
Imports MySql.Data.MySqlClient
Public Class Form1
Dim conn As New MySqlConnection
Dim reader As MySqlDataReader
Public Sub connect()
Dim DatabaseName As String = "CTCL_Strategy"
Dim server As String = "192.168.1.80"
Dim userName As String = "xyz"
Dim password As String = "xyz@123"
If Not conn Is Nothing Then conn.Close()
conn.ConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; pooling=false", server, userName, password, DatabaseName)
Try
conn.Open()
MsgBox("Connected")
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
connect()
Try
conn.Open()
Catch ex As Exception
End Try
Dim cmd As New MySqlCommand("Select * from Employee", conn)
cmd.ExecuteNonQuery()
Reader = cmd.ExecuteReader
Dim table As New DataTable
DataGridView1.DataSource = table
reader.Close()
conn.Close()
End Sub
End Class
but when i run this application I am getting
message :
"unable to connect to any of the specified hosts"
I need help on what else has to be done for the connection.