943,774 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3260
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 29th, 2009
0

Connecting to a Remote Database(mySQL) on LAN

Expand Post »
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=192.168.1.4;" & _ 
                                "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"
Similar Threads
Reputation Points: 8
Solved Threads: 7
Junior Poster
yorro is offline Offline
119 posts
since Aug 2009
Aug 29th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

are u sure its "user id" instead of "uid" ?
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Aug 29th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

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")

VB.NET Syntax (Toggle Plain Text)
  1. A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
Last edited by yorro; Aug 29th, 2009 at 11:51 pm.
Reputation Points: 8
Solved Threads: 7
Junior Poster
yorro is offline Offline
119 posts
since Aug 2009
Aug 29th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

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.
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Aug 29th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

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")

VB.NET Syntax (Toggle Plain Text)
  1. A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll


I've replaced MsgBox("Connection Failed") with this
VB.NET Syntax (Toggle Plain Text)
  1. Select Case Err.Number
  2. Case 1041 : MsgBox("Error: Server error")
  3. Case 1044 : MsgBox("Error: DB Error")
  4. Case 1045 : MsgBox("Error: Access denied")
  5. Case 1049 : MsgBox("Error: DB Error - Check the DB Name")
  6. Case Else
  7. MsgBox("Error: " & Err.Number)
  8. End Select

I receive this display "Error: 5"
Last edited by yorro; Aug 29th, 2009 at 11:54 pm.
Reputation Points: 8
Solved Threads: 7
Junior Poster
yorro is offline Offline
119 posts
since Aug 2009
Aug 29th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

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.
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Aug 29th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

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?
Reputation Points: 8
Solved Threads: 7
Junior Poster
yorro is offline Offline
119 posts
since Aug 2009
Aug 30th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

yes. but make sure u set on "Hosts" % (allow from all)
Last edited by GeekByChoiCe; Aug 30th, 2009 at 12:05 am.
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Aug 30th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

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 = %"
Reputation Points: 8
Solved Threads: 7
Junior Poster
yorro is offline Offline
119 posts
since Aug 2009
Aug 30th, 2009
0

Re: Connecting to a Remote Database(mySQL) on LAN

told ya

can u set this thread to solved please?
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: sql server does not allow to remote connection.
Next Thread in VB.NET Forum Timeline: Changing/Switching to Forms Without Seeing the Desktop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC