I am attempting to create a Login form which compares the info that the user enters against a MySQL database for verification. However, when entering the correct information, I still get a failed login.
Here is the code:
The SQL info is not as it appears here, but is valid when I do a Try.
Here is the code:
Code:
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim user As String
Dim pass As String
Dim tstUsr As String
Dim tstPss As String
'Database Info
conn = New MySqlConnection()
conn.ConnectionString = "server=[URL unfurl="true"]www.sqlserver.com;user[/URL] id=sqllogin;password=sqlpassword;database=sqldb"
'Holds login values
user = txtUsr.Text
pass = txtPss.Text
conn.Open()
'Gets SQL values from server and stores as String
tstUsr = "SELECT `users`.`loginname` FROM 'users'"
tstPss = "SELECT 'users'.'password' FROM 'users'"
If user = tstUsr And pass = tstPss Then
frmMain.Show()
Me.Hide()
Me.Close()
conn.Close()
Else
conn.Close()
lblStatus.Text = "Incorrect Login Information!"
End If
End Sub
The SQL info is not as it appears here, but is valid when I do a Try.