sam1fletcher
Registered User.
- Local time
- Today, 01:29
- Joined
- Jan 28, 2013
- Messages
- 40
Hey All
Basically i have connect my program to an MySql database
I have a while loop which i think the code is fine but wont work properly.
it basically checks the username and password in if is not correct create a simple MsgBox.
If the username and password is correct then is works also if the username is correct but the password isnt it works. But as soon as the username is wrong nothing happens any clue why??
conn is my database pathname
any ideas??
Basically i have connect my program to an MySql database
I have a while loop which i think the code is fine but wont work properly.
it basically checks the username and password in if is not correct create a simple MsgBox.
If the username and password is correct then is works also if the username is correct but the password isnt it works. But as soon as the username is wrong nothing happens any clue why??
Code:
Try
conn.Open()
Dim sqlquery As String = "SELECT * FROM NewTable WHERE Username = '" & username.Text & "';"
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 = password.Text Then
PlayerRegistered.Show()
' Me.Close()
Else
failed.Show()
End If
Else
MsgBox("failed pleas try again")
End If
End While
Catch ex As Exception
End Try
conn is my database pathname
any ideas??