我作的考勤登录,原来能登录,但不能限制重复登录,我重新增加了判断Iswork的函数来限制重复登录后,却总是显示错误类型:
ADODB.Recordset (0x800A0E7D)
连接无法用于执行此操作。在此上下文中它可能已被关闭或无效。.到底错哪儿了?请各位前辈高人帮看看,代码如下:
<%
Response.Expires = 0  'expires属性指定了在浏览器上缓冲存储的页距过期还有多少时间。设置response.expires=0,则使缓存的页面立即过期。
Function checkenter() '判断是否有非法输入
    If username<>"" and password<>"" and otherpwd<>"" and Instr(username,"'")<1 and Instr(username," ")<1 and Instr(username,"""")<1 and Instr(username,"&")<1 then
        checkenter=TRUE  '允许进行用户验证
    Else
        checkenter=FALSE '不允许进行用户验证
    End If
End Function

Function checksysUser() '系统用户验证
    sql="SELECT * FROM fdb_man WHERE user='"&username&"'"
    Set rs=Server.CreateObject("adodb.recordset")
    rs.Open sql,conn,1,1
    if rs.eof then
        checksysUser=FALSE
        Session("passed")=False
    else
        passwd=trim(rs("pwd"))
        if passwd=password then
           checksysUser=TRUE
           Session("passed")=True
           Session("level")=rs("level")
           Session("admin")=rs("admin")           
        else
           checksysUser=FALSE
           Session("passed")=False
        end if
    End if
    rs.close
    conn.close
End Function
Function IsOnline()
    set rs=server.createobject("adodb.recordset")
    mysql ="SELECT * FROM kaoqing_table WHERE user='"&username&"' and recordYear="&Year(Now())&" and recordMonth="&Month(Now())&" and recordDay="&Day(Now())&""
    rs.Open mysql,conn,1,1
     If Iswork=0 Then
      IsOnline = True
   Else
      IsOnline = False
   End If
   
   objRS.Close
   Set objRS = Nothing
End Function
%>
<HTML>
<HEAD>
<TITLE>用户分级登录、有效性验证</TITLE>
<script language="VBScript">
<!--
   Sub login_OnClick
      Dim msg
      msg = ""
      If fus.stxm.value = "" Then
         msg = "姓名不能为空!请先选择..."
         fus.stxm.focus
      End If
      If msg = "" Then
         fus.submit    
      ElseIf fus.pwd.value = "" Then
         msg = "密码不能为空!请先输入..."
         fus.stid.focus
      ElseIf Len(fus.pwd.value) < 4 Or _
             Not IsNumeric(fus.pwd.value) Then
         msg = "密码由4位数字组成!请修改..."
         fus.pwd.focus         
      Else
         Alert(msg)
      End If
   End Sub

   Sub reset_OnClick
      fus.pwd.value = ""
      fus.stxm.value = ""
      fus.pwd.focus
   End Sub
-->
</script>
</HEAD>

<BODY bgColor=#FFFFFF topMargin=0 leftmargin="0" onload="return window_onload()">
<p align="center"><b><font size="6" color="#6699FF">发电部考勤系统欢迎你登录</font></b></p>
<%
if Request.Form("action")="true" then
   username=trim(Request.Form("username"))      '登录用户名
  password=trim(Request.Form("password"))      '登录密码
  otherpwd = Trim(Request.form("otherpwd"))    '附加码
  reotherpwd = Trim(Request.form("reotherpwd"))'生成的附加码
  
  legalTag=checkenter()

  If legalTag=TRUE then '如果没有非法输入,则进行用户验证
    if otherpwd = reotherpwd then  '附加码比较
      legalUserTag=checksysUser()  '系统用户验证 
      if legalUserTag=true then
         If Session("level")=1 and Session("admin")="True"  Then
            Response.Redirect("manage.asp")
            Response.End
         End If        
        If Session("level")=2  Then
        Response.Redirect("main.asp")
        Response.End
        End If
        If Session("level")=3  and IsOnline = True Then 
         set rs=server.createobject("adodb.recordset")
         insertsql="select * from kaoqing_table"
         rs.open insertsql,db,1,3
         rs.addnew
         rs("user")=username
         rs("recordYear")=Year(Now())
         rs("recordMonth")=Month(Now())
         rs("recordDay")=Day(Now())
         rs("recordTime")=Time
         rs("Iswork")=1
         rs("note")=note 
  
         rs.update
    
         rs.close
        set rs=nothing
       Response.Redirect("normal.asp")
         Response.End
         End If

         else
        errmsg="<font color=#FF0000><b>用户名或者用户密码错误,请重新输入!</b></font>"
      end if
    else
      errmsg="<font color=#FF0000><b>附加码输入错误,请重新输入!</b></font>"
    end if
  else
    errmsg="<font color=#FF0000><b>用户名输入有误,请重新输入!</b></font>"
  end if
end if 
%>