| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 199 人关注过本帖
标题:[求助]ASP问题,如何解决对象打开和关闭错误?
取消只看楼主 加入收藏
vert60
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-10-16
收藏
 问题点数:0 回复次数:0 
[求助]ASP问题,如何解决对象打开和关闭错误?
程序里有好几个rs1.open和close,是不是由于没有循环的原因没有配对,或者顺序错误,请指教:

<%
dim chkyear,chkmonth,monthdiff,dt,thisday,wtime1,wtime2,worktime,onewkt,oneptwkt,twowkt,threewkt,fre,wh1,wh2,whin,whmore,n,m,wkw1,weekmoretime,monthmoretime,weeknum

chkyear=request("chkyear")
chkmonth=request("chkmonth")
If chkyear="" Or chkmonth="" Then
'Response.Write("<script language=javascript>window.confirm('数据输入不完整?');</"+"script>")
response.redirect("wage.asp")
else
wkdate=chkyear&"-"&chkmonth '年+月
dt=chkyear&"-"&chkmonth&"-1" '当月第一天
monthdiff = DateDiff("d", DateAdd("m", -1, DateAdd("m", 1, dt)), DateAdd("m", 1, dt)) '获得一个月有几天
monthdiff=cint(monthdiff)
end if

dim rs,empnum,rs1,rs2
Set rs1=server.createobject("adodb.recordset")
Set rs=db.execute("select distinct empno from dbo.employee where empno='11344'")
response.Write("begion")
do while not rs.eof
empnum=rs("empno")
caldate=dt
set rs2=db.execute("select * from dbo.attendpunch where empno='"&empnum&"' and (punchtime between '"&caldate&"' and dateadd(d,"&cint(monthdiff-1)&",'"&caldate&"'))")
if not(rs2.eof and rs2.bof) Then
onewkt=0
oeptwkt=0
twowkt=0
threewkt=0
allmoretime=0
weekmoretime=0
weeknum=1
For i=1 To monthdiff-1
fre=0
strsql="select * from restdate where restdate ='"&caldate&"'" '寻找是不是休息天
'rs1.close
'set rs1=nothing
rs1.open strsql,db,1,1
if rs1.recordcount > 0 then
fre=rs1("valid")
End If
calday=weekday(caldate)
If calday=1 then
if weekmoretime>20*60 then
strsql="insert into error(insert_date,empnum,errordate,reason,status)values('"&date()&"','"&empnum&"','"&wkdate&"第"&weeknum&"周','"&weekmoretime&"','4')"
db.execute(StrSql)
end if
allmoretime=allmoretime+weekmoretime
weekmoretime=0
weeknum=weeknum+1
end if
rs1.close
strsql="select * from attendpunch where empno='"&empnum&"' and punchtime between '"&caldate&"' and dateadd(d,1,'"&caldate&"') order by punchtime"
'strsql="select punchtime from dbo.attendpunch where empno='12020' and punchtime between '2007-05-17' and dateadd(d,1,'2007-05-17')"
'Set rs1=db.execute("select * from attendpunch where punchtime like '%"&caldate&"%' order by punchtime")
rs1.open strsql,db,1,1
wtime1=""
wtime2=""
If rs1.recordcount =1 Then
strsql="insert into error(insert_date,empnum,errordate,reason,status)values('"&date()&"','"&empnum&"','"&caldate&"','one-time','1')"
db.execute(StrSql)
Else If rs1.recordcount >1 then
wtime1=rs1("punchtime")
wtime1=left(wtime1,10)&" "&right(wtime1,8)
wh1=Right(wtime1,8)
rs1.movelast
wtime2=rs1("punchtime")
wtime2=left(wtime2,10)&" "&right(wtime2,8)
wh2=Right(wtime2,8)
rs1.close
If wh1>"07:30:00" Or wh2<"16:30:00" Then '迟到早退
strsql="insert into error(insert_date,empnum,errordate,reason,status) values('"&date()&"','"&empnum&"','"&caldate&"','"&wh1&wh2&"','less-time','2')"
db.execute(StrSql)
End If
If fre=0 Then
onewkt=onewkt+8
cldate=caldate&" 16:30:00"
whin= DateDiff("n",wtime2,cldate)
If (whin mod 60)>30 Then
oneptwkt=oneptwkt+whin/60+1
else
oneptwkt=oneptwkt+whin/60
End If
weekmoretime=weekmore+whin
If (whin>180) Then
strsql="insert into error(insert_date,empnum,errordate,reason,status)values('"&date()&"','"&empnum&"','"&caldate&"','"&(whin)&"','3')"
db.execute(StrSql)
End if
ElseIf fre=2 Then
whin= DateDiff("n",wtime2,wtime1)
If (whin mod 60)>30 then
twokt=twokt+whin/60+1
Else
twokt=twokt+whin/60
End If
weekmoretime=weekmore+whin
'If (whin>8) Then
'strsql="insert into error(insert_date,empnum,errordate,reason,status)values('"&date()&"','"&empnum&"','"&caldate&"','"&(whin)&"','3.2')"
'db.execute(StrSql)
'End if
Elseif fre=3 Then
whin= DateDiff("n",wtime2,wtime1)
If (whin mod 60)>30 then
threekt=threekt+whin/60+1
Else
threekt=threekt+whin/60
End If
weekmoretime=weekmore+whin
'If (whin>8) Then
'strsql="insert into error(insert_date,empnum,errordate,reason,status)values('"&date()&"','"&empnum&"','"&caldate&"','"&(whin)&"','3.3')"
'db.execute(StrSql)
'End if
End if
End if
caldate=DateAdd("d", i, dt)
'next
if allmoretime>80*60 then
strsql="insert into error(insert_date,empnum,errordate,reason,status)values('"&date()&"','"&empnum&"','"&wkdatem&"月','"&allmoretime&"','5')"
db.execute(StrSql)
end if
strsql="insert into worktime(insert_date,empnum,wkdate,onewkt,oneptwkt,twowkt,threewkt)values('"&Date()&"','"&empnum&"','"&caldate&"','"&onewkt&"','"&oneptwkt&"','"&twowkt&"','"&threewkt&"')"
db.execute(StrSql)
end if
rs.movenext
next
response.Write("ok")
end if

Loop
%>
2007-10-16 09:24
快速回复:[求助]ASP问题,如何解决对象打开和关闭错误?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033451 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved