Hello,
I wanted my windows form to be connected to the online database,
I mean I have a mysql database on phpmyadmin, on my hosting provider.
I am creating a windows form that must get data from this database.
i downloaded and installed the connector, and used a code to connect to the data base but i get a error that says "Unable to connect to any of the specified MySQL hosts.
What I have tried:
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class Form1
Dim con As New MySqlConnection
Dim cmd As New MySqlCommand
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "server=localhost;port=3306; user id=myuserid; password=mypassword; database=mydatabasename"
con.Open() 'Error is in this line
cmd.Connection = con
Dim adp As New MySqlDataAdapter
Dim ds As New DataSet
cmd.CommandText = "Select fname from table_name where name='xyz'"
Me.TextBox1.Text = ToString(cmd.ExecuteScalar)
End Sub
End Class
I am sorry if I am not clear in any basis, but i need help