I have a function called GetRS which takes in a SQL string and returns a
recordset object. Does this mean that a copy of the recordset is returned or
is it passed by reference?

Obviously this could have a large impact on performance for large
recordsets.

Re: Functions pass by ref or by value? by Egbert

Egbert
Sat Aug 27 13:42:14 CDT 2005


"Joe" <joe@hotmail.com> wrote in message
news:uFzSZMzqFHA.248@TK2MSFTNGP14.phx.gbl...
>I have a function called GetRS which takes in a SQL string and returns a
>recordset object. Does this mean that a copy of the recordset is returned
>or is it passed by reference?
>
> Obviously this could have a large impact on performance for large
> recordsets.
>

Hi,

If you pass an object 'byval' it is passed as (for instance _Recordset*
pRs), while 'byref' in C++ code, would be _Recordset** pRs.

In the first, case, a pointer to the instance of the object is sent, in the
second case, a pointer to the pointer of the instance. As you understand,
you don't create a in memory-copy.

When we speak about VARIANTS, which is default for ASP and vbscript, the
same happens (more or less) with instances of objects.
But when a variant, contains a string or a date, when passed 'byval', a
fresh copy is made which is obviously slower. In our current time :),
speaking about a normal server, a PIV 3GH this is peanuts. The real benefit
is when your SQL code or other network related functions halt thread
execution.


Re: Functions pass by ref or by value? by Bob

Bob
Sat Aug 27 18:34:20 CDT 2005

Joe wrote:
> I have a function called GetRS which takes in a SQL string and
> returns a recordset object. Does this mean that a copy of the
> recordset is returned or is it passed by reference?
>
> Obviously this could have a large impact on performance for large
> recordsets..

Objects are always passed by reference (given that they are not crossing
process bondaries)

http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx
http://blogs.msdn.com/ericlippert/archive/0001/01/01/53005.aspx

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"