pa help mysql vb.net may table aq sa database na userID,Name,Password pag nag enter aq userID dapat lalabas din ung name sa txtName.text nya ,,e2 po ung code may error laging column not found
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim con As New MySqlConnection("host=localhost; username=root; password=pass; database=login;")
Dim cmd As New MySqlCommand
Dim dr As MySqlDataReader
con.Open()
cmd.Connection = con
cmd.CommandText = "select UserID,Password from login_tb where UserID='" & txtUserID.Text & "'and Password='" & txtPassword.Text & "'"
dr = cmd.ExecuteReader
While dr.Read
frmTime_in.txtName.Text = dr.GetString("Name")
End While
If dr.HasRows Then
Me.Close()
frmTime_in.MdiParent = Main
frmTime_in.Show()
Else
MessageBox.Show("You have enetered an invalid password. Please try again.", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtUserID.SelectAll()
txtPassword.Focus()
End If
con.Close()
End Sub
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim con As New MySqlConnection("host=localhost; username=root; password=pass; database=login;")
Dim cmd As New MySqlCommand
Dim dr As MySqlDataReader
con.Open()
cmd.Connection = con
cmd.CommandText = "select UserID,Password from login_tb where UserID='" & txtUserID.Text & "'and Password='" & txtPassword.Text & "'"
dr = cmd.ExecuteReader
While dr.Read
frmTime_in.txtName.Text = dr.GetString("Name")
End While
If dr.HasRows Then
Me.Close()
frmTime_in.MdiParent = Main
frmTime_in.Show()
Else
MessageBox.Show("You have enetered an invalid password. Please try again.", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtUserID.SelectAll()
txtPassword.Focus()
End If
con.Close()
End Sub