实时错误'91':
对象变量或 With块变量未设置
Dim msg As String
Dim SQL As String
Private Sub CmdOK_Click()
Dim rst As ADODB.Recordset
Dim password As String
'判断密码是否正确
Sys_UserID = Trim(txtUserId.Text)
SQL = " select 用户ID,密码 from 用户信息表 where 用户ID='" & Sys_UserID & "'"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then '如果存在该用户 提示此行出错
password = Trim(rst.Fields(1))
rst.Close
Else
If InsertUserInfo Then
MsgBox ("欢迎读者使用,请你修改密码!")
Else
MsgBox ("用户ID或密码错误!")
End If
Exit Sub
End If
If password = Trim(txtPassword.Text) Then
Sys_LoginSucceeded = True
图书管理系统.Show
Unload Me
Else
MsgBox ("密码错误!")
Sys_LoginSucceeded = False
End If
End Sub
Private Function InsertUserInfo() As Boolean
'如果输入的是读者号,且用户是第一次登陆,自动添加到用户列表
'返回true,如果不是读者号,返回false
Dim rst As ADODB.Recordset
SQL = " select * from 读者信息表 where 读者号='" & Sys_UserID & "'"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then '如果存在该读者
SQL = "insert into 用户信息表(用户ID,用户名称,用户类别,密码,权限,身份证号,住址,电话,邮箱) "
SQL = SQL & " select 读者号,姓名,'读者' as 用户类别,读者号,"
SQL = SQL & " '借书管理 : 还书管理 : 检索统计 :' as 权限,身份证号,住址,电话,邮箱 "
SQL = SQL & " from 读者信息表 where 读者号='" & Sys_UserID & "'"
Call ExecuteSQL(SQL, msg)
InsertUserInfo = True
Else
InsertUserInfo = False
End If
rst.Close
End Function
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
Sys_LoginSucceeded = False
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
Sys_LoginSucceeded = False
Unload Me
End Sub