locked
vb10 mysqlconnector /net can't connect to mysql host RRS feed

  • Question

  • Hi,

    i'm making a program where you must login with username and password.

    These things are located in mysql server on my website (remote).

    But it always gives me the error : wasn't able to connect to any of the speciefied mysqlhosts.

    This is my script the * are the adresses and id's and passwords place.

    Dim connect As New MySqlConnection
            connect.ConnectionString = "server=********.000webhost.com;user id=*********_admin;password=2******hd;database=********_login"
            If TextBox1.Text = "" And TextBox2.Text = "" Then
                MsgBox("Username and password fields cannot be empty !", MsgBoxStyle.Critical, "Oeps...")
            Else
                Try
                    connect.Open()
    
                Catch ex As Exception
                    MsgBox("Couldn't connect to database !MYSQL error message=" + ex.Message + "|Customstuff Wizard will now abort")
                    Me.DestroyHandle()
    
    
    
    
                End Try
                Dim myadapter As New MySqlDataAdapter
                Dim sqlquery = "SELECT * FROM users WHERE username='" & TextBox1.Text & "' AND password='" & TextBox2.Text & "'"
                Dim mycommand As New MySqlCommand
                mycommand.Connection = connect
                mycommand.CommandText = sqlquery
                myadapter.SelectCommand = mycommand
                Dim mydata As MySqlDataReader
                mydata = mycommand.ExecuteReader
                If mydata.HasRows = 0 Then
                    MsgBox("Username or password is incorrect , couldn't find username: " + TextBox1.Text + "with password: " + TextBox2.Text, MsgBoxStyle.Critical, "Oeps...")
                Else
                    NotifyIcon1.ShowBalloonTip(2500, "Login system", "Login is loading your account...", ToolTipIcon.Info)
                    Me.DestroyHandle()
                    upper.Show()
                    welcome.Show()
                End If
    
    
            End If
    

    Does anyone knows what the problem is ?

    oh and the host says remote mysql is enabled.

    Thanks

    Monday, February 13, 2012 4:58 PM

Answers

  • It would appear that your connection string is incorrect. I see UID and PWD in the examples at the below link:

    http://connectionstrings.com/mysql#p28


    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Proposed as answer by Mark Liu-lxf Wednesday, February 15, 2012 3:03 AM
    • Marked as answer by Mark Liu-lxf Tuesday, February 21, 2012 6:41 AM
    Monday, February 13, 2012 5:13 PM
  • Hi VirtualArts,

    The default port of MYSQL is 3306, if your ISP blocks the port, you can’t connect with MySQL. Do you have permission to change the port of MySQL? If yes, you need to change the port of MySQL and also add the new port number in your connection string. If not, it seems no other way to connect to database if the ISP is still blocking.

    Hope this helps.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Mark Liu-lxf Tuesday, February 21, 2012 6:41 AM
    Thursday, February 16, 2012 5:15 AM

All replies

  • It would appear that your connection string is incorrect. I see UID and PWD in the examples at the below link:

    http://connectionstrings.com/mysql#p28


    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Proposed as answer by Mark Liu-lxf Wednesday, February 15, 2012 3:03 AM
    • Marked as answer by Mark Liu-lxf Tuesday, February 21, 2012 6:41 AM
    Monday, February 13, 2012 5:13 PM
  • I changed it to Uid and Pwd it's still the same error
    Monday, February 13, 2012 6:47 PM
  • Hi VirtualArts,

    Welcome to the MSDN forum.

    I think Paul give the correct direction. We can’t reappear your issue, so I’m afraid you need to check some information by yourself. You need to check the existence of server, check the port number, ID and the Password. If you can make sure your connect string is correct, you need to pay more attention to the setting of MySQL, you can connect to the MySQL official website to ask for help.

    Hope this helps.   


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, February 15, 2012 5:34 AM
  • i think that my problem is that my isp is blocking port 3306,

    if i'am correct this port is used for Mysql connections ?

    Is there any other solution for a login system with a remote database ?

    Wednesday, February 15, 2012 1:57 PM
  • Hi VirtualArts,

    The default port of MYSQL is 3306, if your ISP blocks the port, you can’t connect with MySQL. Do you have permission to change the port of MySQL? If yes, you need to change the port of MySQL and also add the new port number in your connection string. If not, it seems no other way to connect to database if the ISP is still blocking.

    Hope this helps.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Mark Liu-lxf Tuesday, February 21, 2012 6:41 AM
    Thursday, February 16, 2012 5:15 AM