INFO: Passing ADO Recordsets in Visual Basic Procedures
ID: Q193871
|
The information in this article applies to:
-
ActiveX Data Objects (ADO), versions 1.5, 2.0
-
Microsoft Visual Basic Professional and Enterprise Editions for Windows, versions 5.0, 6.0
-
Microsoft Visual Studio versions 6.0, 97
SUMMARY
This article describes the expected behavior when passing ActiveX Data
Objects (ADO) recordset objects in Visual Basic procedures. The behavior
depends on a number of factors including the value of the CursorLocation
property, whether you pass the recordset in process or out of process, and
whether you pass the recordset ByRef or ByVal.
MORE INFORMATION
In Process
If you pass an ADO recordset in process, you are passing a reference to an
object in memory regardless of whether you attempt to pass the recordset
variable ByRef or ByVal and regardless of the setting of the CursorLocation
property.
Out Of Process
When you pass an ADO recordset out of process, the ADO libraries are loaded
in both processes. The ADO libraries pass the information stored in the
recordset from the one process to the other. Each process now has its own
copy of the recordset object rather than a reference to the initial object.
The bookmark, filter, and sort information are not used in determining what
records to pass across process boundaries. All rows of the recordset are
passed, regardless of the current setting of the Filter property. In the
resulting recordset, the first record is the current record regardless of
the bookmark set in the other process. The resulting recordset does not
receive the value of the Sort property from the other process.
The MarshalOptions property can be used to control whether the whole Recordset or only the modified rows are marshalled.
If you pass the variable ByRef, the data for the recordset is passed back
to the calling procedure. This can cause an unnecessary performance hit and
should be avoided whenever possible. Unless you want the changes made
within the procedure to be returned to the calling procedure, do not pass
the recordset ByRef. Keep in mind that if you set MarshalOptions to
adMarshalModifiedOnly and pass the recordset ByRef, that at the end of the
call to the server the client has a recordset that contains only the
modified rows.
If you pass the variable ByVal, then the recordset is not returned from the
procedure. This means that your recordset remains in the same state as it
was before the call to the procedure. The modified rows are still marked as
having been modified.
You can only pass an ADO recordset out of process if it's CursorLocation is
adUseClient. You should also set the recordset's ActiveConnection property
to Nothing before passing it out of process.
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by David
Sceppa, Microsoft Corporation.
Additional query words:
Keywords : kbADO kbADO150 kbADO200 kbDatabase
Version : WINDOWS:1.5,2.0,5.0,6.0,97
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: April 23, 1999