Private Sub Command1_Click()
Dim xg As String
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
xg = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\xsgl.mdb"
cn.Open xg
rs.Open "select * from dl", cn, adOpenKeyset, adLockPessimistic
If rs.RecordCount > 0 Then
If Text1.Text = "" Then
MsgBox "请输入用户名", vbOKOnly + vbCritical, "登陆错误"
Text1.SetFocus
Exit Sub
End If
If Text1.Text <> "" Then
Set rs1 = New ADODB.Recordset
rs1.Open "select * from dl where user_id='" & Text1.Text & "'", cn, adOpenKeyset, adLockPessimistic
Text2.SetFocus
If rs1.RecordCount > 0 Then
If Text2.Text <> "" Then
rs1.Open "select * from dl where user_power='" & Text2.Text & "'", cn
Command1.SetFocus
If rs1.Fields("user_id") = Text1.Text And rs1.Fields("user_power") = Text2.Text Then
form2.show
unload.me
Else
MsgBox "信息错误!", vbExclamation + vbOKCancel, "登陆错误"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End If
End If
End If
End If
End Sub
https://bbs.bccn.net/thread-229890-1-1.html