Code
1<%
2Dim dbfile,dbfore,dbback,connstr,conn,sqlstr,rs
3dbfile="#db.mdb"
4dbfore="db/" & dbfile
5dbback="../" & dbfore
6Sub openConn(dbfile)
7 On Error Resume Next
8 connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(dbfile)
9 Set conn=Server.CreateObject("Adodb.Connection")
10 conn.open connstr
11 if err then
12 err.clear
13 closeConn()
14 showerr("连接数据库出错,请联系管理员!")
15 response.end
16 end if
17End Sub
18Sub closeConn()
19 On Error Resume Next
20 if isobject(conn) then
21 if conn.State=adStateOpen then
22 conn.close()
23 Set conn=Nothing
24 end if
25 end if
26End Sub
27Sub openRS(sqlstr,attr)
28 On Error Resume Next
29 Set rs=Server.CreateObject("ADODB.RecordSet")
30 rs.open sqlstr,conn,1,CLng(attr)
31 if err then
32 err.clear
33 closeRS()
34 closeConn()
35 showerr("打开记录集出错,请联系管理员!")
36 response.end
37 end if
38End Sub
39Sub closeRS()
40 On Error Resume Next
41 if isobject(rs) then
42 If rs.State<>0 Then
43 rs.Close
44 Set rs = Nothing
45 End If
46 end if
47End Sub
48
49function echo(str)
50 Response.Write str & vbcrlf
51end function
52
53Sub goback()
54 dim address
55 address = request.ServerVariables("HTTP_REFERER")
56 Response.Write "<script>window.location.href='" & address & "';</script>"
57End Sub
58Sub 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>"
61End Sub
62Sub goaddr(addr)
63 Response.Write "<script type='text/javascript'>window.location.href='" & addr & "';</script>"
64End Sub
65Sub message(msg)
66 Response.Write "<script type='text/javascript'>alert('" & msg & "');</script>"
67End Sub
68sub showErr(msg)
69 dim errhtml
70 errhtml="<div style='background:#369;color:white;height:30px;line-height:30px;text-indent:1em;'>Error: " & msg & "</div>"
71 Response.Write errhtml
72end sub
73%>
1<%
2Dim dbfile,dbfore,dbback,connstr,conn,sqlstr,rs
3dbfile="#db.mdb"
4dbfore="db/" & dbfile
5dbback="../" & dbfore
6Sub openConn(dbfile)
7 On Error Resume Next
8 connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(dbfile)
9 Set conn=Server.CreateObject("Adodb.Connection")
10 conn.open connstr
11 if err then
12 err.clear
13 closeConn()
14 showerr("连接数据库出错,请联系管理员!")
15 response.end
16 end if
17End Sub
18Sub closeConn()
19 On Error Resume Next
20 if isobject(conn) then
21 if conn.State=adStateOpen then
22 conn.close()
23 Set conn=Nothing
24 end if
25 end if
26End Sub
27Sub openRS(sqlstr,attr)
28 On Error Resume Next
29 Set rs=Server.CreateObject("ADODB.RecordSet")
30 rs.open sqlstr,conn,1,CLng(attr)
31 if err then
32 err.clear
33 closeRS()
34 closeConn()
35 showerr("打开记录集出错,请联系管理员!")
36 response.end
37 end if
38End Sub
39Sub closeRS()
40 On Error Resume Next
41 if isobject(rs) then
42 If rs.State<>0 Then
43 rs.Close
44 Set rs = Nothing
45 End If
46 end if
47End Sub
48
49function echo(str)
50 Response.Write str & vbcrlf
51end function
52
53Sub goback()
54 dim address
55 address = request.ServerVariables("HTTP_REFERER")
56 Response.Write "<script>window.location.href='" & address & "';</script>"
57End Sub
58Sub 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>"
61End Sub
62Sub goaddr(addr)
63 Response.Write "<script type='text/javascript'>window.location.href='" & addr & "';</script>"
64End Sub
65Sub message(msg)
66 Response.Write "<script type='text/javascript'>alert('" & msg & "');</script>"
67End Sub
68sub showErr(msg)
69 dim errhtml
70 errhtml="<div style='background:#369;color:white;height:30px;line-height:30px;text-indent:1em;'>Error: " & msg & "</div>"
71 Response.Write errhtml
72end sub
73%>