MySQL connection error [VB.Net]

Status
Not open for further replies.

synthica

New Member
Messages
1
Reaction score
0
Points
0
I'm currently trying to connect to a database that I made on my free hosting account. The reason I made it was for my app that I'm creating. It has a login system and also a create account area that I'm trying to connect this database to.

The current code I'm using to connect is:

MySqlConnection = New MySqlConnection
MySqlConnection.ConnectionString = "Server=localhost;Database=database_name;Uid=Username;Pwd=password"
MySqlConnection.Open()


Dim Myadapter As New MySqlDataAdapter
Dim sqlquary = "SELECT * From Users WHERE username='" & TextBox1.Text & "'AND password='" & TextBox2.Text & "';"
Dim command As New MySqlCommand
command.Connection = MySqlConnection
command.CommandText = sqlquary
Myadapter.SelectCommand = command
Dim Mydata As MySqlDataReader
Mydata = command.ExecuteReader
If Mydata.HasRows = 0 Then
MsgBox("You must provide a valid Username and Password.")
Else
Mainstation.Show()
Me.Close()
End If

I've typed all the information in correct although it keeps saying it cannot connect. I've been using another Database with the same code and it's worked fine.

If anyone knows please let me know. Thank's
 
Last edited:

Skizzerz

Contributors
Staff member
Contributors
Messages
2,928
Reaction score
118
Points
63
You cannot connect to a MySQL database on your hosting account from anywhere except your hosting account -- remote MySQL is disabled on free hosting.
 
Status
Not open for further replies.
Top