[thelist] ASP/VBScript question

Anthony Baratta Anthony at Baratta.com
Thu Oct 10 12:55:01 CDT 2002

At 10:35 AM 10/10/2002, David.Cantrell at Gunter.AF.mil wrote:
>Is it possible to return an object ByVal from a function, instead of ByRef?

I think this is what you want, not sure. My VBS Skills are porous when it
comes to understanding completely how the under the cover works.

     Set objDBConn = NewDBConn()

'' NewDBConn Function
'' Required Info Passed to Function:
''      None
Function NewDBConn()
     Set objNewDBConn = Server.CreateObject("ADODB.Connection")
     Set NewDBConn = objNewDBConn
     Set objNewDBConn = Nothing
End Function

>Alternately, is it possible to retrieve an object ByVal when using a Set
>statement, e.g. "Set obj = MyClass.Recordset" returns a copy of "Recordset"
>instead of a reference to it? When MyClass is destroyed, so is the reference
>internally to Recordset, and if Recordset is destroyed, the reference set
>with obj is destroyed as well.

Because the Connection Object is the base on which you create record sets,
I don't think you can have a record set "stand alone". There are such
things as disconnected record sets, but I've never used them.

If you want to work with Record Sets without having to keep the record set
object open and if your return results are "small" suck all the results
into an array using GetRows function.

Hope that helps.

Anthony Baratta
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."

More information about the thelist mailing list