Actually, I believe my first post in this thread has already solved the problem! The connection object is an object, and must therefore be assigned to as the function's return by using the SET keyword! I don't know how to make it any plainer!
However, there's a little more to it than that... Miranda is correct in pointing out that the object is being set to nothing before the close of the function and is therefore being killed as the function currently stands, but since in VBScript you cannot truly dispose an object until *all* the variables which reference it have been set to nothing (or go out of scope)
, as soon as the code is corrected to use the SET keyword (as already stated above), the function will *still* return a valid connection object as expected.
Of course, it goes without saying that the line setting the object to equal nothing is *completely* superfluous and should be removed, but I just wanted to point out that it doesn't actually mess anything up (once the real error is corrected) because of the way that object references work. (So it's a red herring.)
Since dereferencing objects is a topic which is often misunderstood, I would like to take this opportunity to clarify it, and so I have written the following demonstration code to make it crystal clear - I hope it's enlightening (and perhaps even surprising!):
'create a Connection object
Set A = Server.CreateObject("ADODB.Connection")
'set B to reference the same object as A
Set B = A
'print the object type of both variables
Response.Write "Start: A=" & TypeName(A) & "<br />"
Response.Write "Start: B=" & TypeName(B) & "<br />"
'set A to nothing
Set A = Nothing
Response.Write "Middle: A=" & TypeName(A) & "<br />"
Response.Write "Middle: B=" & TypeName(B) & "<br />"
'and finally set B to nothing
Set B = Nothing
Response.Write "End: A=" & TypeName(A) & "<br />"
Response.Write "End: B=" & TypeName(B) & "<br />"
Now are the results what you were expecting?!
And Scott, once you add the "Set" keyword as I indicated, does the function function?!
And you STILL haven't said what line 78 is!!!