0

In my VB.NET Application I check for the connection whether it is successful or not.

Dim conString As String = "server=public ip here; port=3306; database=test; uid=test; pwd=testp"

Public Function CheckServer() As Boolean
        mySqlCon = New MySqlConnection
        mySqlCon.ConnectionString = conString

        Try
            mySqlCon.Open()
            mySqlCon.Close()
            MsgBox("Connected!")
            Return True
        Catch ex As MySqlException
            MsgBox("Connection failed!", MsgBoxStyle.Critical)
            Return False
        Finally
            mySqlCon.Dispose()
        End Try
End Function

My issue is that when I publish this test application and send it to my friend to test it, he always get the error connection failed.

Here is what I have done if it helps :

  1. Port forwarded port 3306 under my private ip address
  2. Edited phpmyadmin.conf file to Allow from all
  3. Edited config.inc.php file 'user' to test
  4. Edited config.inc.php file 'password' to testp
  5. Edited config.inc.php file 'host' to 192.168.0.x (my private ip)
  6. Edited config.inc.php file 'Allow no password' to false
  7. In phpmyadmin, under User settings, I have grant full privileges to test and set host to %

Conclusion : I understand that by doing this I risk having to loosen up my security and stuff but I am fine with this as this is just a test PC for me to learn. Nothing important or whatsoever in here.

So how do I access the WAMP database in my current PC with a VB.NET application if it was started on another PC on another network?

Student
  • 432
  • 2
  • 10
  • 30
  • Do you have a `MySQL Connector for Visual Studio` installed ? This required to connect to MySQL using VS – Mahadev Aug 16 '15 at 06:45
  • Yes I do have it installed or else I wont even be able to add mysql.data – Student Aug 16 '15 at 06:46
  • Ok. Is there anything specific exception or Error you are getting ? – Mahadev Aug 16 '15 at 06:47
  • Just "unable to connect to any of the specified hosts" – Student Aug 16 '15 at 06:48
  • Use word 'localhost` instead of `IP Address` in server parameter. – Mahadev Aug 16 '15 at 06:51
  • And according to [http://stackoverflow.com/questions/22962923/unable-to-connect-to-any-of-the-specified-mysql-hosts-when-checking-connection] (This Link), re-installation of WAMP might work. Have you tried that ? – Mahadev Aug 16 '15 at 06:52
  • I am able to connect through localhost but that is not my purpose. For an example, I give you a copy of my application and you run it. I want the application to connect to my database here. – Student Aug 16 '15 at 06:57
  • Well, if you tried to connect to MySQL database over the internet, VS doesn't allow that. VS doesn't allow third party connections while using MySQL. I have had that problem before and i found that you can't connect to MySQL using VS over the internet. On LAN, it might be possible but for that you must allow connections and authenticate credentials between two PCs – Mahadev Aug 16 '15 at 07:03
  • Ah I see. So there's no any way to connect the application over internet? – Student Aug 16 '15 at 07:44
  • 1
    There's a way. But for that you need to deploy the app over the internet. Its not possible using VS. – Mahadev Aug 16 '15 at 07:50
  • Alright thanks for your clarification. – Student Aug 16 '15 at 10:05
  • He is not using VS, I assume he has compiled an exe and given that to his friend, so all this VS stuff is irrelevant. **Dont reinstall WAMPServer** you run the risk of loosing your databases. – RiggsFolly Aug 18 '15 at 08:19
  • Did you intend to give your friend access to phpMyAdmin or just the MySQL Database you created for this program to use? – RiggsFolly Aug 18 '15 at 08:28
  • @RiggsFolly Both. And I am able to do it already :) – Student Aug 18 '15 at 08:30

0 Answers0