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
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: