Sun
ONE Active Server Pages Product Home Page Developer Site Version
 

ContentsPreviousNextIndex



ADO Recordset Object Clone Method

Creates a duplicate Recordset object from an existing Recordset object. This method is not currently supported on UNIX.

Clone Method Syntax
Set rstDuplicate = rstOriginal.Clone ()
Clone Method Parameters

rstDuplicate

An object variable identifying the duplicate Recordset object you're creating.

rstOriginal

An object variable identifying the Recordset object you want to duplicate.

Clone Method Remarks

Use the Clone method to create multiple, duplicate Recordset objects, particularly if you want to be able to maintain more than one current record in a given set of records. Using the Clone method is more efficient than creating and opening a new Recordset object with the same definition as the original.

The current record of a newly created clone is set to the first record.

Changes you make to one Recordset object are visible in all of its clones regardless of cursor type. However, once you execute the ADO Recordset Object Requery Method on the original Recordset, the clones will no longer be synchronized to the original.

Closing the original recordset does not close its copies; closing a copy does not close the original or any of the other copies.

You can only clone a Recordset object that supports bookmarks. Bookmark values are interchangeable; that is, a bookmark reference from one Recordset object refers to the same record in any of its clones.

Clone Method Return Values

Returns a Recordset object reference.

ADO Recordset Object Close Method

Closes an open object and any dependent objects.

Close Method Syntax
object.Close
Close Method Remarks

Use the Close method to close a Recordset object to free any associated system resources. Closing an object does not remove it from memory; you may change its property settings and open it again later. To completely eliminate an object from memory, set the object variable to Nothing.

Using the Close method to close a Recordset object releases the associated data and any exclusive access you may have had to the data through this particular Recordset object. You can later call the ADO Recordset Object Open Method to reopen the Recordset with the same or modified attributes. While the Recordset object is closed, calling any methods that require a live cursor generates an error.

If an edit is in progress while in immediate update mode, calling the Close method generates an error; call the ADO Recordset Object Update Method or ADO Recordset Object CancelUpdate Method first. If you close the Recordset object during batch updating, all changes since the last ADO Recordset Object UpdateBatch Method call are lost.

If you use the Clone method to create copies of an open Recordset object, closing the original or a clone does not affect any of the other copies.

Close Method Examples

This VBScript example uses the Open and Close methods on both Recordset and Connection objects that have been opened.

<!-- #Include file="ADOVBS.INC" --> 
<HTML><HEAD> 
<TITLE>ADO 1.5 Open Method</TITLE> 
</HEAD><BODY> 
<FONT FACE="MS SANS SERIF" SIZE=2> 
<Center><H3>ADO Open Method</H3> 
<TABLE WIDTH=600 BORDER=0> 
<TD VALIGN=TOP ALIGN=LEFT COLSPAN=3><FONT SIZE=2> 
<!--- ADO Connection used to create 2 recordsets--> 
<% 
Set OBJdbConnection = Server.CreateObject("ADODB.Connection") 
OBJdbConnection.Open "AdvWorks" 
SQLQuery = "SELECT * FROM Customers" 
'First Recordset RSCustomerList 
Set RSCustomerList = OBJdbConnection.Execute(SQLQuery) 
'Second Recordset RsProductist 
Set RsProductList = Server.CreateObject("ADODB.Recordset") 
RsProductList.CursorType = adOpenDynamic 
RsProductList.LockType = adLockOptimistic 
RsProductList.Open "Products", OBJdbConnection 
%> 
<TABLE COLSPAN=8 CELLPADDING=5 BORDER=0>
<!-- BEGIN column header row for Customer Table--> 
<TR><TD ALIGN=CENTER BGCOLOR="#008080"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Company Name</FONT></TD> 
<TD ALIGN=CENTER BGCOLOR="#008080"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Contact Name</FONT></TD> 
<TD ALIGN=CENTER WIDTH=150 BGCOLOR="#008080"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>E-mail address</FONT></TD> 
<TD ALIGN=CENTER BGCOLOR="#008080"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>City</FONT></TD> 
<TD ALIGN=CENTER BGCOLOR="#008080"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>State/Province</FONT></TD></TR>
<!--Display ADO Data from Customer Table--> 
<% Do While Not RScustomerList.EOF %> 
<TR><TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RSCustomerList("CompanyName")%> 
</FONT></TD> 
<TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RScustomerList("ContactLastName") & ", " %> 
<%= RScustomerList("ContactFirstName") %> 
</FONT></TD> 
<TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RScustomerList("ContactLastName")%> 
</FONT></TD> 
<TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RScustomerList("City")%> 
</FONT></TD> 
<TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RScustomerList("StateOrProvince")%> 
</FONT></TD></TR> 
<!-Next Row = Record Loop and add to html table--> 
<% 
RScustomerList.MoveNext 
Loop 
RScustomerList.Close 
OBJdbConnection.Close 
%> 
</TABLE> 
<HR> 
<TABLE COLSPAN=8 CELLPADDING=5 BORDER=0> 
<!-- BEGIN column header row for Product List Table--> 
<TR><TD ALIGN=CENTER BGCOLOR="#800000"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Product Type</FONT></TD> 
<TD ALIGN=CENTER BGCOLOR="#800000"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Product Name</FONT></TD> 
<TD ALIGN=CENTER WIDTH=350 BGCOLOR="#800000"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Product Description</FONT></TD> 
<TD ALIGN=CENTER BGCOLOR="#800000"> 
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Unit Price</FONT></TD></TR> 
<!-- Display ADO Data Product List--> 
<% Do While Not RsProductList.EOF %> 
<TR> <TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RsProductList("ProductType")%> 
</FONT></TD> 
<TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RsProductList("ProductName")%> 
</FONT></TD> 
<TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RsProductList("ProductDescription")%> 
</FONT></TD> 
<TD BGCOLOR="f7efde" ALIGN=CENTER> 
<FONT STYLE="ARIAL NARROW" SIZE=1> 
<%= RsProductList("UnitPrice")%> 
</FONT></TD> 
<!-- Next Row = Record --> 
<% 
RsProductList.MoveNext 
Loop 
'Remove Objects from Memory Freeing 
Set RsProductList = Nothing 
Set OBJdbConnection = Nothing 
%> 
</TABLE></FONT></Center></BODY></HTML>


ContentsPreviousNextIndex