it wont Connect to Database using the String Formats any help please

Imports MySql.Data.MySqlClient
Imports MySql.Data

Module Connect

Public Conn As New MySqlConnection
Private ConnStr As String
Dim Result As Boolean


Public Function MySQLConn() As Boolean


    Try


        Dim Hostname As String
        Dim Port As Integer
        Dim Username As String
        Dim Password As String
        Dim Database As String
        
        'Using Text Box on Form 
        Hostname = FrmMySQLConnct.TxtHostname.Txt
        Port = FrmMySQLConnct.TxtPort.Txt
        Username = FrmMySQLConnct.TxtUsername.Txt
        Password = FrmMySQLConnct.TxtPassword.Txt
        Database = FrmMySQLConnct.TxtDatabase.Txt


        If Conn.State = ConnectionState.Closed Then
            ConnStr = "Server=Hostname;Port=Port;UID=Username;Pwd=Password;DB=Database;"

            Dim Connection As New MySqlConnection(ConnStr)
            Conn.ConnectionString = ConnStr
            Conn.Open()
            Result = True

            FrmMain.Label1.Text = "Connected"

        Else

            FrmMain.Label1.Text = "Disconected"


        End If

    Catch ex As Exception

        Result = False


    End Try

    Return Result
End Function

End Module

2 answers

Looks like you are not using the retrieved variable values in the connection string.

i already fix my problem but thanks for your help