04-21-2012, 04:01 PM
Hi,
I've been successfully using the example code from your YouTube tutorials "How to implement a database into VB.NET" for quite sometime but for some reason I cannot get my code to work when I run my Wamp Server on another machine. I use exactly the same code with exactly the same database/setup as what I have locally on my dev PC and with free SQL hosting sites like db4free.net without issues.
The above code works fine for a local connection but if I were to change the connection to another PC running on my local network then it wont connect. The connection string would be something like:
I've tried changing ports, opened ports in my firewall, uninstalled / reinstalled changing server to pc name etc but nothing seems to work (Wamp Server is Set to Online).
I can connect fine to phpmyadmin using <!-- m --><a class="postlink" href="http://192.168.0.150:8080/phpmyadmin/">http://192.168.0.150:8080/phpmyadmin/</a><!-- m --> from any PC in my network but I just can't get the .NET code to connect.
So I'm all out of ideas and thought I'd post here to see if anyone else has any suggestions.... please... getting desperate now <!-- s --><img src="{SMILIES_PATH}/icon_e_sad.gif" alt="" title="Sad" /><!-- s -->
Thanks
Ben
I've been successfully using the example code from your YouTube tutorials "How to implement a database into VB.NET" for quite sometime but for some reason I cannot get my code to work when I run my Wamp Server on another machine. I use exactly the same code with exactly the same database/setup as what I have locally on my dev PC and with free SQL hosting sites like db4free.net without issues.
Code:
Imports MySql.Data.MySqlClient
Public Class Form1
Public conn As MySqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
conn = New MySqlConnection("server=localhost; user id=someuserid; password=somepassword; database=somedatabase")
Try
conn.Open()
Dim sqlquery As String = "SELECT * FROM useraccess where Username = 'someusername';"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = sqlquery
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader
While data.Read()
If data.HasRows() = True Then
If data(2).ToString = "somepassword" Then
MsgBox("Login")
Else
MsgBox("Failed Login")
End If
Else
MsgBox("Failed Login")
End If
End While
Catch ex As Exception
End Try
End Sub
End Class
The above code works fine for a local connection but if I were to change the connection to another PC running on my local network then it wont connect. The connection string would be something like:
Code:
conn = New MySqlConnection("server=192.168.0.150; port=8080; user id=someuserid; password=somepassword; database=somedatabase")
I've tried changing ports, opened ports in my firewall, uninstalled / reinstalled changing server to pc name etc but nothing seems to work (Wamp Server is Set to Online).
I can connect fine to phpmyadmin using <!-- m --><a class="postlink" href="http://192.168.0.150:8080/phpmyadmin/">http://192.168.0.150:8080/phpmyadmin/</a><!-- m --> from any PC in my network but I just can't get the .NET code to connect.
So I'm all out of ideas and thought I'd post here to see if anyone else has any suggestions.... please... getting desperate now <!-- s --><img src="{SMILIES_PATH}/icon_e_sad.gif" alt="" title="Sad" /><!-- s -->
Thanks
Ben