Private Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click
mysqlconn.Open()
cmd.CommandText = "select * from login "
cmd.Connection = mysqlconn
dr = cmd.ExecuteReader
dr.Read()
If txtuser.Text = "" And txt_password.Text = "" Then
MsgBox("Please enter user name and password", MsgBoxStyle.Information, "Login form")
Else
If txtuser.Text = "" Then
MsgBox("Please select user name", MsgBoxStyle.Information, "Login form")
Else
If txt_password.Text = "" Then
MsgBox("Please enter password", MsgBoxStyle.Information, "Login form")
'If (dr.FieldCount > 0) Then
'Dim i As Integer = dr(1)
' For i = 1 To dr.FieldCount
'user = dr("user").ToString
' password = dr("password").ToString
ElseIf ((txtuser.Text = '" & txt_username.text & "') And (txt_password.Text = '" & txt_password.text & "')) Then
form2.Show()
Else : MsgBox("Password missmatch.", vbCritical, "Invalid password")
End If
End If
End If
dr.Close()
cmd.Dispose()
mysqlconn.Close()
mysqlconn.Dispose()
End Sub
我有一个表登录。用户名和密码是两列。我试图从上面代码中的登录表中获取应用程序中的用户名和密码,但我无法从登录表中获取第二行条目,因为我有两个 rowrs(1) 用户名=abc,passowrd=abc 2) 用户名=xyz,密码=xyz) 我如何在运行时获得第二个登录条目?谢谢