locked
VB.NET MySQL Application Will Not Connect on Clients Windows 10 64-bit PC... RRS feed

  • Question

  • Hi,

    I have built an application in VB.NET to connect to a MySQL database to check users registration, but here is the message that they keep getting each time that they try to run the application and check registration:

    "Unable to connect to any of the specified MySQL hosts."


    Here is the VB.NET code that I'm using to connect:

    'MysqlConn.ConnectionString = "server=198.27.87.232;userid=MyUserID;password=MyPassword;database=aaronest_ekspdb"
    
    'AND I HAVE TRIED:
    
    MysqlConn.ConnectionString = "Server=198.27.87.232;Port=3306;Database=aaronest_ekspdb;Uid=MyUserID;Pwd=MyPassword;"


    But still, my client only see's the following message:
    "Unable to connect to any of the specified MySQL hosts."


    The software will connect and run great on most of my clients computers, but for some reason, every now and then, some clients receive the message above.

    I have also tried to unblock my clients ports on her Windows 10 firewall to no avail.

    Would appreciate the support.




    • Edited by KareninstructorMVP Thursday, February 21, 2019 6:16 PM Removed annoying bold text
    Thursday, February 21, 2019 5:46 PM

All replies

  • Hello,

    it's one computer and only happens "every now and then", what resolves the issue currently?

    I would doubt it's a computer setting but instead a) intermittent pause with their connection. Not knowing how long until they can connect with no problem perhaps implement several retries to connected e.g. fail to connection alert the user, wait x amount of second then retry until the max count is reached or user cancels.

    Lastly, if a tech person could run Fiddler inspector and look for issues this might help. 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, February 21, 2019 6:20 PM
  • Hi Karen,

    What I meant was that it seems to run on most of my clients machines, but every now and then, a couple of them will report this issue to me.

    As for the timeout or retries, what is an example of code or possibly a snippet you could send me just as an example? That would be great.

    As for Fiddler, I have a little bit of experience, but my client is in Israel with her computer and not sure how that would work. What would I look for or how would I recognize the issue? Would Fiddler directly show me the connection error or issue? I'm not sure about that idea.

    Thanks again for your ideas Karen.

    Thursday, February 21, 2019 6:52 PM
  • Fiddler would show errors.

    In the future please refrain from posting text in bold, it's extremely difficult to read at least for me and implies shouting which is uncool.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, February 21, 2019 7:18 PM
  • So how did you architecture the solution? Did you use a client/server architecture style implementing speration of concerns where the database access code is  behind a server application running on another computer, a multi user application doing CRUD with the database on the behalf of the client?

    hthttps://docs.microsoft.com/en-us/previous-versions/msp-n-p/ee658117(v=pandp.10)tps://en.wikipedia.org/wiki/Separation_of_concerns

    https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ee658117(v=pandp.10)

    Or possibly a 3-tier solution where the Windows form solution on client computer is not in direct contact with the database server. The client application would call upon the  server program with the Data Access Layer sitting behind it to do CRUD with the database.

    Yes. this can be done with a Windows form client. 

    A firewall has nothing to do with your problems. The Windows 10 O/S is one of the worst O/S(s) MS has ever put out that can have issues like the one you are experiencing. 



    • Edited by DA924x Thursday, February 21, 2019 7:38 PM
    Thursday, February 21, 2019 7:37 PM
  • So how did you architecture the solution? Did you use a client/server architecture style implementing speration of concerns where the database access code is  behind a server application running on another computer, a multi user application doing CRUD with the database on the behalf of the client?

    hthttps://docs.microsoft.com/en-us/previous-versions/msp-n-p/ee658117(v=pandp.10)tps://en.wikipedia.org/wiki/Separation_of_concerns

    https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ee658117(v=pandp.10)

    Or possibly a 3-tier solution where the Windows form solution on client computer is not in direct contact with the database server. The client application would call upon the  server program with the Data Access Layer sitting behind it to do CRUD with the database.

    Yes. this can be done with a Windows form client. 

    A firewall has nothing to do with your problems. The Windows 10 O/S is one of the worst O/S(s) MS has ever put out that can have issues like the one you are experiencing. 



    The user will access the database remotely in which this MySQL database is located on my web hosting which grants remote access permissions. 

    Here is the exact connection code that I'm using:

    Dim MysqlConn As MySqlConnection
        Dim COMMAND As MySqlCommand
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            'ACTIVATE:
            MysqlConn = New MySqlConnection
            'MysqlConn.ConnectionString = "server=198.27.87.232;userid=MyUserID;password=MyPassword;database=aaronest_ekspdb"
            MysqlConn.ConnectionString = "Server=198.27.87.232;Port=3306;Database=aaronest_ekspdb;Uid=MyUserID;Pwd=MyPassword;"
            Dim READER As MySqlDataReader
    
            If TextBox1.Text.Count >= 2 And TextBox2.Text.Count >= 2 And TextBox3.Text.Count >= 10 And TextBox3.Text.Contains("@") And TextBox4.Text.Count >= 15 Then
                Try
                    MysqlConn.Open()
                    Dim Query As String
                    Query = "select * from table1 where FirstName='" & TextBox1.Text & "' and LastName='" & TextBox2.Text & "' and Email='" & TextBox3.Text & "' and SerialLicense='" & TextBox4.Text & "'"
                    COMMAND = New MySqlCommand(Query, MysqlConn)
    
    
                    READER = COMMAND.ExecuteReader
                    Dim count As Integer
                    count = 0
                    While READER.Read
                        count = count + 1
                    End While
    
                    If count >= 1 Then
                        'Write the credentials file if successfully activated:                
                        Dim SW As New System.IO.StreamWriter(testfile)
                        SW.Write(TextBox1.Text & "," & TextBox2.Text & "," & TextBox3.Text & "," & TextBox4.Text)
                        SW.Close()
    
                        MsgBox("Thanks for registering " & TextBox1.Text & "!")
    
                        Form1.Show()
                        Me.Hide()
                    Else
                        MsgBox("Make sure that you have entered the ""Activation Information"" EXACTLY as it was sent to you by email. This form is CASE-SENSITIVE.", , "eBay Keyword Sniper Pro")
                    End If
    
                    MysqlConn.Close()
    
                Catch ex As MySqlException
                    MsgBox(ex.Message)
                Finally
                    MysqlConn.Dispose()
                End Try
            End If
    
        End Sub

    So that database is stored in my web hosting in the phpMyAdmin section. I'm sure that the hosting provider has allowed access as most of my clients have been able to connect. It's just some of them who are receiving this message:

    "Unable to connect to any of the specified MySQL hosts."

    Not sure why.

    Thursday, February 21, 2019 9:28 PM
  • The user will access the database remotely in which this MySQL database is located on my web hosting which grants remote access permissions. 

    A Web service should be there with a Data Access Layer,  a classlib project,  sitting behind the Web service. The Web service calls upon an object in the DAL, a Data Access Object to do CRUD with the database. Everything about the database is accessed through the Web service using the DAL, and the Web.config for the Web service has the connectionstring that the DAL objects will use in accessing the database with the required database logic

    The Web service is consumed by the Web form client and the Web service  acts on the behalf of the client to do CRUD with the database. The client is a thin clinet that has no direct database access with code to the database, even remotely.

    If no database logic is on the client machine and it is setting out there on a Web server that you have tested the code on the Web server for connections to the database with no problems on the backend, then there can be no problems with the client machine, becuase the client has no database connectivity logic on the client machine.

    https://en.wikipedia.org/wiki/Data_access_object

    I can show you how to use the DAO pattern. I can show you how to use the DAO pattern in the DAL. I can show you how you can make  an ASP.NET WebAPI Web service in VB.NET too if you like.

    Thursday, February 21, 2019 10:49 PM