Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySQL / Wamp Server Issues
#1
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.

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 <!-- sSad --><img src="{SMILIES_PATH}/icon_e_sad.gif" alt="Sad" title="Sad" /><!-- sSad -->

Thanks

Ben
#2
I got it worked out in the end...

Just in case it helps anyone else here's what I didn't do correctly the first time.

I needed to forward port 3306 (I did TCP & UDP).

Doh!!
#3
Doh! Well I'm glad you got it working!! <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->
My Blog | My Setup | My Videos | Have a wonderful day.


Possibly Related Threads…
Thread Author Replies Views Last Post
  please Help Me Vb sign up with MySql.Data.MySqlClient hohoswithcans 1 9,497 04-20-2012, 03:23 PM
Last Post: brandonio21
  connect to mysql client cry1978 2 10,265 07-12-2011, 11:09 AM
Last Post: brandonio21
  MySQL Module xolara 4 15,697 04-16-2011, 12:28 AM
Last Post: xolara

Forum Jump:


Users browsing this thread: 1 Guest(s)