3、清空对象
当使用完对象后,首先使用Close方法来释放对象所占用的系统资源;然后设置对象值为“nothing”释放对象占用内存。当年,我就是在一张页面上创建了百余个没有清空对象的记录集而崩溃了我的IIS。下面的代码使用数据库内容建立一个下拉列表。代码示例如下:
<% myDSN="DSN=xur;uid=xur;pwd=xur"
mySQL="select * from authors where AU_ID<100"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
if rstemp.eof then
response.write "数据库为空"
response.write mySQL
conntemp.close
set conntemp=nothing
response.end
end if%>
<%do until rstemp.eof %>
<%
rstemp.movenext
loop
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
上一页 [1] [2] [3] [4] [5] [6] 下一页