Private Function ExecuteSQL(SQL As String)End FunctionPrivate Sub cmdOK_Click()
Dim sname As String, spas As String
Dim mrs As ADODB.Recordset, strsql As String
'ADODB.Recordset需要添加“Microsoft ActiveX Data Object [版本号,比如2.8等] Library”
sname = Trim(txtUerName.Text): spas = Trim(txtPassword.Text)
'数据有效性检查
If sname = "" Then
MsgBox "请输入用户名!", vbCritical, "用户登录验证"
txtUerName.SetFocus
Exit Sub
End If
If spas = "" Then
MsgBox "请输入密码", vbCritical, "用户登录验证"
txtPassword.SetFocus
Exit Sub
End If
'检查用户名是否正确
strsql = "select * from login where user='" & sname & " '"
'查询所有User= Sname变量值的行,显示所有列
Set mrs = ExecuteSQL(strsql)
'executesql为标准模块中自定义的通用查询函数
If mrs.EOF = True Then
MsgBox "用户名不存在!", vbCritical, "用户登录验证"
try_times = try_times + 1
If try_times >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将关闭", vbCritical, "用户登录验证"
  End
Else
  txtUerName.SetFocus: txtUerName.SelStart = 0
  txtUerName.SelLength = Len(txtUerName.Text)
  Exit Sub
 End If
End If
strsql = "select * form login where user='" & sname & "'" & "and password='" & spas & ","
Set mrs = ExecuteSQL(strsql)
If mrs.EOF = True Then
MsgBox "密码错误!", vbCritical, "用户登录验证"
try_times = try_times + 1
If try_times >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将关闭", vbCritical, "用户登录验证"
  End
Else
  txtPassword.SetFocus: txtPassword.SelStart = 0
  txtPassword.SelLength = Len(txtPassword.Text)
  Exit Sub
 End If
End If
MsgBox "登录成功!", vbInformation, "用户登录验证"
'保存当前登录的权限
bolauthority = mrs.Fields("admin")
'加载MDI主窗体
Unload Me
End Sub我运行的时候这句Set mrs = ExecuteSQL(strsql) 老报错误:要求对象!
前辈们能不能帮我分析下原因哈!谢谢!