'判断是否已经关闭了 所以重复关闭时不会出错
If IsObject(conn) Then
If Not (conn Is nothing) then
If conn.state=1 Then
conn.close
Set conn=nothing
Else
Set conn=nothing
End If
End if
End If
'下面这些代码用于在脚本执行的最后关闭数据库连接 放到conn.asp文件即可 每个使用数据库的页面包含conn.asp后 就会自动在页面的最后关闭数据库
set inull=new ImNull
class ImNull
Private Sub Class_Terminate
If IsObject(conn) Then
If Not (conn Is nothing) then
If conn.state=1 Then
conn.close
Set conn=nothing
Else
Set conn=nothing
End If
End if
response.Write "<!--End-->"
End If
End Sub
end class