Connecting to a Remote Database(mySQL) on LAN

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2009
Posts: 94
Reputation: yorro has a little shameless behaviour in the past 
Solved Threads: 6
yorro yorro is offline Offline
Junior Poster in Training

Connecting to a Remote Database(mySQL) on LAN

 
0
  #1
Aug 29th, 2009
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"
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 53
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

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

 
0
  #2
Aug 29th, 2009
are u sure its "user id" instead of "uid" ?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 94
Reputation: yorro has a little shameless behaviour in the past 
Solved Threads: 6
yorro yorro is offline Offline
Junior Poster in Training

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

 
0
  #3
Aug 29th, 2009
Originally Posted by GeekByChoiCe View Post
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")

  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 53
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

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

 
0
  #4
Aug 29th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 94
Reputation: yorro has a little shameless behaviour in the past 
Solved Threads: 6
yorro yorro is offline Offline
Junior Poster in Training

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

 
0
  #5
Aug 29th, 2009
Originally Posted by GeekByChoiCe View Post
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")

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


I've replaced MsgBox("Connection Failed") with this
  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 53
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

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

 
0
  #6
Aug 29th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 94
Reputation: yorro has a little shameless behaviour in the past 
Solved Threads: 6
yorro yorro is offline Offline
Junior Poster in Training

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

 
0
  #7
Aug 29th, 2009
Originally Posted by GeekByChoiCe View Post
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?
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 53
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

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

 
0
  #8
Aug 30th, 2009
yes. but make sure u set on "Hosts" % (allow from all)
Last edited by GeekByChoiCe; Aug 30th, 2009 at 12:05 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 94
Reputation: yorro has a little shameless behaviour in the past 
Solved Threads: 6
yorro yorro is offline Offline
Junior Poster in Training

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

 
0
  #9
Aug 30th, 2009
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 = %"
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 53
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

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

 
0
  #10
Aug 30th, 2009
told ya

can u set this thread to solved please?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC