INFO: Passing ADO Recordsets in Visual Basic Procedures (193871)
The information in this article applies to:
- ActiveX Data Objects (ADO) 1.5
- ActiveX Data Objects (ADO) 2.0
- ActiveX Data Objects (ADO) 2.1 SP2
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q193871 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 INFORMATIONIn 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.
Modification Type: | Minor | Last Reviewed: | 3/2/2005 |
---|
Keywords: | kbDSupport kbinfo KB193871 |
---|
|