MySQL connection Error

Lance

New member
Joined
Nov 8, 2006
Messages
2
Programming Experience
1-3
Kinda web development....
This is my problem.
I have a MySQL database installed on my USB stick
This is so that i can work on my project at school which is horrible to connect to the internet, but it will be on the internet in the end
I have a program made in VB.net which should connect to the MySQL database via Connector/Net, but constantly gives me the error message
"Cannot connect to any of the specified MySQL hosts"

VB.NET:
Imports MySql.Data.MySqlClient
------------------------------------------------------------------
Public Class frmlogin
    Dim conn As MySqlConnection
    Dim VarUser
    Dim VarPass
------------------------------------------------------------------
    Private Sub cmdlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdlogin.Click
        conn = New MySqlConnection()
        conn.ConnectionString = "Server=localhost;Database=member;Uid=lance;""Pwd=test123;"
        Try
            conn.Open()
            MessageBox.Show("Connection Established to server")
            conn.Dispose()

There is a bit more to the code, but it isnt directly to do with connecting to the database, it is mostly to do with what the program does (secure login which is why i didnt post it up for obvious reasons)
When i try i do disable Firewalls (including windows firewall) and also Anti-virus but no luck...
I have made an attempt to connect to an online database with the same problem...
I am sure someone must know the solution, if you do please tell me.
As i am doing my nut on this one!

Thanks in advance

Lance

P.S
I can connect to the database via MySQL admin and add records to it via query browser. So i think there isnt a problem with the database...
 
Do you see the difference in this connection string:
VB.NET:
 conn.ConnectionString = "Server=localhost;Database=member;Uid=lance;Pwd=test123;"
 
minor error on my behalf, originally that was as you stated...

but even changed to the correct version i still cannot access :(

any other ideas?
 
To connect to a mySQL DB in Vb.net:


VB.NET:
Dim conn As New MySqlConnection
Dim myConnectionString As String
 
myConnectionString = "server=localhost;" _
& "user id=username;" _
& "password=password;" _
& "database=in_out"
 
Try
conn.ConnectionString = myConnectionString
conn.Open()
 
Catch ex As MySqlException
Select Case ex.Number
Case 0
MessageBox.Show("Cannot connect to server. Contact administrator")
Case 1045
MessageBox.Show("Invalid username/password, please try again")
End Select
 
End Try
 
Last edited by a moderator:
Back
Top