VISUAL BASIC: how to connect a MySQL database with VISUAL STUDIO 2022

Viewed 44

I'm really need some help to connnect MySQL database with VISUAL STUDIO 2022, using VB. My server is in "localhost". I used this lines of code:

Imports MySql.Data.MySqlClient
Imports Microsoft.VisualBasic.ApplicationServices
Imports Microsoft.Win32

Public Class Form1
Dim sqlConn As New MySqlConnection
Dim sqlCMD As New MySqlCommand
Dim sqlRd As MySqlDataReader
Dim sqlDt As New DataTable
Dim DtA As New MySqlDataAdapter

Dim server As String = "localhost"
Dim username As String = "root"
Dim password As String = "root"
Dim database As String = "empleados"

Private bitmap As Bitmap

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Try
        sqlConn.Open()
        MsgBox("Conexion exitosa!")
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

End Class

But when I execute the programm, it brings me this ERROR:

MySql.Data.MySqlClient.MySqlException (0x80004005): Host '192.168.0.205' is not allowed to connect to this MySQL server
   en MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   en MySql.Data.MySqlClient.NativeDriver.Open()
   en MySql.Data.MySqlClient.Driver.Open()
   en MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   en MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   en MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   en MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   en MySql.Data.MySqlClient.MySqlPool.GetConnection()
   en MySql.Data.MySqlClient.MySqlConnection.Open()
   en WindowsApp1.Form1.Button1_Click(Object sender, EventArgs e) en C:\Users\mad\Desktop\PROGRAMACIÓN\VB.NET\repos\WindowsApp1\WindowsApp1\Form1.vb:línea 23

Someone knows what is this error about? Thanks!

0 Answers
Related