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
我有一个表login.username和密码是两个columns.I想从上面的代码登录表获取应用程序的用户名和密码,但因为我有两个我无法获取从登录表第二行条目rowrs(1)username = abc,passowrd = abc 2)username = xyz,password = xyz) 我将如何在运行时获得第二次登录入口? 谢谢如何在运行时从mysqldatabase获取第二行?
如果我这样做dr.read()---申请受理在用户名和密码文本框中输入的所有值,但我想,以配合数据库是否它(用户名和密码,一行)存在,然后只导航到其他形式 – 2012-07-12 10:21:20
正是!如果dr.Read()然后导航其他窗体,否则该表(用户名,密码)不存在。 – 2012-07-12 10:24:42