How to read per row in a table in mySQL as the database? i want each username when they login, they will go to their respective forms. Like for example, there are 3 users and each user have their different forms. can someone help me with this... thank you!
This is my code:
Dim conn As MySqlConnection
Dim myCommand As New MySqlCommand
Dim dr As MySqlDataReader
conn = New MySqlConnection("server=localhost; Uid=myid; Pwd=mypass; database=useraccounts")
myCommand = New MySqlCommand("SELECT * FROM useraccount where username='" & txtUsername.Text.ToLower & "'", conn)
Try
conn.Open()
dr = myCommand.ExecuteReader
dr.Read()
If txtUsername.Text.ToLower.Equals(dr(0)) And txtPassword.Text.Equals(dr(1)) Then
MsgBox("Welcome!", MsgBoxStyle.Information, "login Successful")
frmAdmin.Show()
Me.Hide()
Else
MsgBox("Password didn't match the username", MsgBoxStyle.Critical, "Login Unsuccessful")
txtbox()
End If
conn.Close()
conn.Dispose()
Catch myerror As MySqlException
MsgBox("Username does not exist", MsgBoxStyle.Critical, "Login Unsuccessful")
txtbox()
Catch myerror As Exception
MsgBox(myerror.ToString)
Environment.Exit(0)
End Try