<% set conn = CreateObject("ADODB.Connection") response.write isObject(conn) response.write isNull(conn) response.write isEmpty(conn) & "<p>" set conn = nothing response.write isObject(conn) response.write isNull(conn) response.write isEmpty(conn) %> |
When the object has been created, isObject() returns true, while isNull() and isEmpty() both return false. When the object has been destroyed, isObject() still returns true, and isNull() and isEmpty() both still return false. This information isn't very useful, as it doesn't change during and after the lifetime of an object.
The criteria you are looking for is whether the object "is nothing", as demonstrated here:
<% set conn = CreateObject("ADODB.Connection") response.write (conn IS NOTHING) & "<p>" set conn = nothing response.write (conn IS NOTHING) & "<p>" if NOT (conn is nothing) then response.write "Destroying conn." set conn = nothing else response.write "conn doesn't exist." end if %> |
Note that some components, e.g. ADODB.Recordset, have properties that will tell you their state. For example, see the last code snippet in
Article #2283.