dim i as integer
i=1Private Sub Command1_Click()if i>3 then end
Set pConn = New ADODB.Connection
pConn.Open "连接到数据库"
Set pRst = New ADODB.Recordset
pRst.CursorLocation = adUseClient
pRst.Open "select 用户名,口令 from 用户记录表", pConn, adOpenKeyset, adLockOptimistic
Do While Not pRst.EOF
If Trim(Me.txtUserName) = Trim(pRst("用户名")) And Trim(Me.txtPassword) = Trim(pRst("口令")) Then
LoginSucceeded = True
Exit Do
Else
LoginSucceeded = False
End If
pRst.MoveNext
Loop
If LoginSucceeded = False Then
MsgBox "用户名或者口令不正确,请重试! " & vbCrLf & "如还不正确请同系统管理员联系!", vbOKOnly + vbInformation, "提示"
Else
MDIMain.Show
Unload Me
End If
pRst.Close
pConn.Close
Set pRst = Nothing
Set pConn = Nothing
i=i+1
end sub
i=1Private Sub Command1_Click()if i>3 then end
Set pConn = New ADODB.Connection
pConn.Open "连接到数据库"
Set pRst = New ADODB.Recordset
pRst.CursorLocation = adUseClient
pRst.Open "select 用户名,口令 from 用户记录表", pConn, adOpenKeyset, adLockOptimistic
Do While Not pRst.EOF
If Trim(Me.txtUserName) = Trim(pRst("用户名")) And Trim(Me.txtPassword) = Trim(pRst("口令")) Then
LoginSucceeded = True
Exit Do
Else
LoginSucceeded = False
End If
pRst.MoveNext
Loop
If LoginSucceeded = False Then
MsgBox "用户名或者口令不正确,请重试! " & vbCrLf & "如还不正确请同系统管理员联系!", vbOKOnly + vbInformation, "提示"
Else
MDIMain.Show
Unload Me
End If
pRst.Close
pConn.Close
Set pRst = Nothing
Set pConn = Nothing
i=i+1
end sub
Option Explicit
Dim Rc1 As Recordset
Dim xstr1 As String
Dim i%Private Sub cmdok_Click()End SubPrivate Sub cmdQuit_Click()
End
End Sub
Private Sub Txtid_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Txtpass.SetFocus
End Sub
Private Sub Txtpass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Kname = "": LocYN = ""
Set DB = OpenDatabase(CurDir & "\NEWSOMCIM.MDB")
' Set Rc1 = Cn.OpenResultset("Select * from username where user11 = '" & trim(text1(0)) & "',user12 = '" & trim(rc1!prgo11) & "',user13 = '" & trim(rc1!prgo12) & "' ", rdOpenKeyset, rdConcurRowVer)
Set Rc1 = DB.OpenRecordset("username", dbOpenTable)
Rc1.Index = "primarykey"
Rc1.Seek "=", Trim(Txtid), "0", "0"
If Rc1.NoMatch = False Then
If Trim(Txtpass) <> Trim(Rc1!user14) Then
MsgBox "无权使用..!", 256, Me.Caption
DB.Close
Txtid = "": Txtpass = ""
Txtid.SetFocus
Exit Sub
Else
LocYN = Rc1!user15
End If
Else
MsgBox "无权使用..!", 256, Me.Caption
DB.Close
Txtid = "": Txtpass = ""
Txtid.SetFocus
Exit Sub
End If
Kname = Trim(Txtid)
Mainmenu.Show
Unload Me
End If
End Sub