I have connected VB.net and mySQL on a the same PC before, but I have no Idea how to connect VB.net to a remote PC(LAN)

I've only changed the server

This is my code. I removed some of the details, but it works on server=localhost

conn = New MySqlConnection()
        conn.ConnectionString = "server=[b]192.168.1.4[/b];" & _ 
                                "user id=root;" & _
                                "password=;" & _ 
                                "database=system"

        Try
            conn.Open()
            MsgBox("You have control")
            conn.Close()
        Catch ex As Exception
            MsgBox("Connection Failed")
        End Try

I have turned off firewalls from both sides, and it keeps returning "Connection Failed"

are u sure its "user id" instead of "uid" ?

are u sure its "user id" instead of "uid" ?

It works when this is connecting with mySQL on the same computer. But not on other computers in the same network(lan)

The program hangs for at least 30 secs then continues with the line: MsgBox("Connection Failed")

A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

well i doubt you have the permission to connect an "extern" database server as root with no password given. did u create a user account on the remote mysql server? then you should use that account. as far as i know form linux u arent allowed to connect with the root account from outside.

well i doubt you have the permission to connect an "extern" database server as root with no password given. did u create a user account on the remote mysql server? then you should use that account. as far as i know form linux u arent allowed to connect with the root account from outside.

My mySQL is just a test server. The mySQL on the same computer is the same from another computer, same account: uid="root" password=""

The program hangs for at least 30 secs then continues with the line: MsgBox("Connection Failed")

A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

I've replaced MsgBox("Connection Failed") with this

Select Case Err.Number
                Case 1041 : MsgBox("Error: Server error")
                Case 1044 : MsgBox("Error: DB Error")
                Case 1045 : MsgBox("Error: Access denied")
                Case 1049 : MsgBox("Error: DB Error - Check the DB Name")
                Case Else
                    MsgBox("Error: " & Err.Number)
            End Select

I receive this display "Error: 5"

yes error 5 is the database connection. and it doesnt matter if the sql server is a testserver. mysql does not accept root connection from another machine but localhost. just create another superuser and connect as this user.

yes error 5 is the database connection. and it doesnt matter if the sql server is a testserver. mysql does not accept root connection from another machine but localhost. just create another superuser and connect as this user.

I'll just create another mySQL account and use that?

yes. but make sure u set on "Hosts" % (allow from all)

OMG Thanks GeeksbyChoice, I can't believe a stayed up all night with this.

To anyone having the same problem
1. Don't Use the default account(user="root";password="";)
2. Create an account, settings of a new account must have "Host = %"

told ya :D

can u set this thread to solved please? :D

So i'll just hit this "Mark as Solved" link?

OMG Thanks GeeksbyChoice, I can't believe a stayed up all night with this.

To anyone having the same problem
1. Don't Use the default account(user="root";password="";)
2. Create an account, settings of a new account must have "Host = %"

sir..... i created a new account on WAMP server.... then.....


i'm using this connection string

conn = New MySqlConnection("server=192.168.1.85; user id=ilearnserver; password=serverilearn; database=ilearn")


then i got an error message:

Unable to connect to any of the specified MySQL hosts.

sir..... i created a new account on WAMP server.... then.....


i'm using this connection string

conn = New MySqlConnection("server=192.168.1.85; user id=ilearnserver; password=serverilearn; database=ilearn")


then i got an error message:

Unable to connect to any of the specified MySQL hosts.

I'm sure you got your WAMP server ONLINE.

Is the 192.168.1.85 the IP of the server?

If yes, check your user privileges. In this case for ilearnserver. Go to http://localhost/phpmyadmin/server_privileges.php. Check if the host is correct.

If no, check your server's IP.

it's the same with my problem? my problem is ..
i need to connect vb.net to mysql using other pc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.