having trouble connecting to mysql database from VB

Posts 13 of 3 · Page 1 of 1
having trouble connecting to mysql database from VB
Hello Friends,

I'm trying to connect to mysql database from vb, my computer is a localhost on which i have mysql and php.

After several tries i dicided to come here and ask for help.

Code:
Imports MySql.Data.MySqlClient

Public Class frmMain
    Dim MySqlConnection As MySqlConnection = New MySqlConnection

       Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
      MySqlConnection.ConnectionString = "Server=localhost;User Id=wilson382;Password=PmYlm123;Database=wil_practice"

        Try
            If MySqlConnection.State = ConnectionState.Closed Then
                MySqlConnection.Open()
                MsgBox("Sucessfully connected to MySQL Database")
            Else
                MySqlConnection.Close()
                MsgBox("Connection failed")
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub
End Class
when i start debugging this is the message that pops up (see the attachments to see the image)
Google'd and found this. This might help you

I atually followed that video to get the codes i have. but i cant figure out why might dont work, i installed namespace that i was missing

edit: i thought this was a small issue, this seens to big a huge topic behind this. while googling i found over 300 threads opened dealing about this issue "MySqlException: Unable to connect to any of the specified MySQL hosts"
Posts 13 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?