Clone method of recordset in VB

Source: Internet
Author: User
When using VB, I found a strange problem, as shown below: Code In the process of generating recordset, the clone method of recordset is called. No operation is performed after the clone, during tracking and time, it is found that the recordset's recordcount for rectemp is 26, but after calling the recordset clone method, it was found that the new Zookeeper rectempcopy After cloning has doubled the rectemp record. Depressed, is there a doubling of the clone capacity? Query msdn. As described above,

UseCloneMethod to create multiple, duplicateRecordsetObjects, special if you want to be able to maintain more than one current record in a given set of records. UsingCloneMethod is more efficient than creating and opening a newRecordsetObject with the same definition as the original.
The current record of a newly created clone is set to the first record.
I don't know how it works?Depressing. I checked out msdn:
Changes you make to oneRecordsetObject are visible in all of its clones regardless of cursor type. However, once you execute requery on the originalRecordset, The clones will no longer be synchronized to the original.

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

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

Checked againCloneAfter the principle, the author of the blogDream of daily InjuryDescriptionClone:To obtain a superficial copy is to directly connect the book to the reader, and to obtain a deep copy is to save (or destroy) the book and copy it to the reader ().

in C #, the copy method of dataset is deep copy, and the clone method is just pull clone.
code:
dim objprv as object 'sysrrvb. clspprv
dim objrectemp as new ADODB. recordset
dim objrectempcopy, rectempcopy1 as new ADODB. recordset
dim strtemp
set objprv = Createobject ("'sysrrvb. clspprv ")
if me. chkdep. value = 1 then
set objrectemp = m_buffer.records (clng (mid (trim $ (Me. trvorg. selecteditem. key), 2, 1)
set objrectempcopy = Objrectemp. clone
set rectempcopy1 = objrectemp
******
end if
the clone method has a lot of details, but I still don't know why double is the original clone object ?, In addition, the added object is not exactly the same as the original object .?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.