Well, there is the IsObject function, but that's not completely reliable.
If you create an object and then destroy it, IsObject will still return a
true if you test if the variable is an object. So, you could use an On
Error Resume Next in conjunction with trying to access a property
(preferably the default property) of your object.
Example:
<%
Dim oADO
Response.Write IsObject(oADO) & " - should be false<br>"
Set oADO = CreateObject("ADODB.Connection")
Response.Write IsObject(oADO) & " - should be true<br>"
Set oADO = Nothing
Response.Write IsObject(oADO) & " - you'd think it'd be false, but it's
true.<br>"
On Error Resume Next
sTemp = oADO.ConnectionString
Response.Write "Is really an object that still exists in memory? " &
(Err.Number = 0)
On Error Goto 0
%>
Ray at work
"Christian Blackburn" <Ch*****************@Damn.Spam@Hotmail.com> wrote in
message news:u6**************@TK2MSFTNGP11.phx.gbl...
Hi Gang,
I want to test and find out whether or not a particular variable object
has
been defined. I need to know whether or not a recordset has already been
defined in the current script. However, my script crashes even though
I've
disabled error handling, which doesn't make a whole lot of sense to me,
but
anyways :). Here's my code:
---------------------------------------------------
on Error Resume Next
If objRS.Fields.GetCount > 1 Then
RestartRecordSet()
Else
OpenConnection()
End If
On Error Goto 0
-----------------------------------------------------
Is there some command like If isdef(objRS) then... or something to that
effect? Also is .GetCount the correct command? I think it is, but MSDN
help has a special way of giving too much information.
Thanks in advance,
Christian Blackburn