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