1
<%2
Dim dbfile,dbfore,dbback,connstr,conn,sqlstr,rs3
dbfile="#db.mdb"4
dbfore="db/" & dbfile5
dbback="../" & dbfore6
Sub openConn(dbfile)7
On Error Resume Next8
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(dbfile)9
Set conn=Server.CreateObject("Adodb.Connection")10
conn.open connstr11
if err then12
err.clear13
closeConn()14
showerr("连接数据库出错,请联系管理员!")15
response.end16
end if17
End Sub18
Sub closeConn()19
On Error Resume Next20
if isobject(conn) then21
if conn.State=adStateOpen then 22
conn.close()23
Set conn=Nothing24
end if25
end if26
End Sub27
Sub openRS(sqlstr,attr)28
On Error Resume Next29
Set rs=Server.CreateObject("ADODB.RecordSet")30
rs.open sqlstr,conn,1,CLng(attr)31
if err then32
err.clear33
closeRS()34
closeConn()35
showerr("打开记录集出错,请联系管理员!")36
response.end37
end if38
End Sub39
Sub closeRS()40
On Error Resume Next41
if isobject(rs) then42
If rs.State<>0 Then43
rs.Close44
Set rs = Nothing45
End If46
end if47
End Sub48

49
function echo(str)50
Response.Write str & vbcrlf51
end function52

53
Sub goback()54
dim address55
address = request.ServerVariables("HTTP_REFERER")56
Response.Write "<script>window.location.href='" & address & "';</script>"57
End Sub58
Sub gotoURL(msg,goaddr)59
Response.Write "<script type='text/javascript'>alert('" & msg & "');</script>"60
Response.Write "<script type='text/javascript'>window.location.href='" & goaddr & "';</script>"61
End Sub62
Sub goaddr(addr)63
Response.Write "<script type='text/javascript'>window.location.href='" & addr & "';</script>"64
End Sub65
Sub message(msg)66
Response.Write "<script type='text/javascript'>alert('" & msg & "');</script>"67
End Sub68
sub showErr(msg)69
dim errhtml70
errhtml="<div style='background:#369;color:white;height:30px;line-height:30px;text-indent:1em;'>Error: " & msg & "</div>"71
Response.Write errhtml72
end sub73
%>