Click here to Skip to main content
15,888,157 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
Mehdi Gholam 6-Jun-15 4:02am    
Make sure the mysql port 3306 is open on the ubuntu machine.
#dev_Preet 6-Jun-15 6:17am    
Its open.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900