Option Explicit
Dim cnt As Integer '记录确定次数
Private Sub Command1_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(Text1.Text) = "" Then '判断输入的用户名是否为空
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Else
sql = "select * from 系统管理 where 用户名='" & Text1.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus Else '检验密码是否正确
If Trim(rs_login.Fields(1)) = Trim(Text2.Text) Then
userID = Text1.Text
userpow = rs_login.Fields(2)
rs_login.Close
Unload Me
MDIForm1.Show
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
Text2.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim connectionstring As String
c
conn.Open connectionstring
cnt = 0
End Sub
这段代码中指针是怎么移动的,text1,text不是与第一个数据库用户名比较,再和第二个比较......依次类推比较,假设到最后一个记录末尾时,说明没有该用户,但是记录指针是怎么移动的啊!没有移动的语句啊(movenext)!难道是指针自己就能移动吗?
Dim cnt As Integer '记录确定次数
Private Sub Command1_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(Text1.Text) = "" Then '判断输入的用户名是否为空
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Else
sql = "select * from 系统管理 where 用户名='" & Text1.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus Else '检验密码是否正确
If Trim(rs_login.Fields(1)) = Trim(Text2.Text) Then
userID = Text1.Text
userpow = rs_login.Fields(2)
rs_login.Close
Unload Me
MDIForm1.Show
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
Text2.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim connectionstring As String
c
conn.Open connectionstring
cnt = 0
End Sub
这段代码中指针是怎么移动的,text1,text不是与第一个数据库用户名比较,再和第二个比较......依次类推比较,假设到最后一个记录末尾时,说明没有该用户,但是记录指针是怎么移动的啊!没有移动的语句啊(movenext)!难道是指针自己就能移动吗?
前面已经使用SQL语句找到符合条件的用户名了 所以只需要比较一次啊.
这时不需要你来移动指针,记录集为空,也移动不了。