|
Private Sub cmdConnect_Click()
Dim txtsql As String
Dim mrc As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim msgtext As String
Dim stokens() As String
username = ""
If IsNull(Me.txtUsername) Then
MsgBox "没有这个用户或未受权,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUsername.SetFocus
Else
txtsql = "select * from 职工资料 where 职工ID='" & txtUsername & "'" ‘提示职工资料无效
stokens = Split(txtsql)
Set cnn = New ADODB.Connection
cnn.Open connectstring
Set rst = New ADODB.Recordset
rst.Open Trim$(txtsql), cnn, adOpenKeyset, adLockOptimistic
Set mrc = rst
If mrc.EOF = True Then
MsgBox "没有这个用户或未受权,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUsername.SetFocus
Else
If Trim(mrc.Fields(20)) = Trim(txtPassword.Text) Then
ok = True
username = Trim(mrc.Fields(1))
userid = Trim(txtUsername.Text)
mrc.Close
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
micount = micount + 1
If micount = 3 Then
MsgBox "输入密码不正确,已经3次!", vbOKOnly + vbExclamation, "警告"
DoCmd.Close
DoCmd.Quit
End If
End If
End If
End If
End Sub
Public Function connectstring() As String
connectstring = "filedsn=ZJGL.dsn;uid=sa;pwd="
End Function |
|