ADO CopyTo Method

Home | About me | EXCEL VB Programming (XL97-2003) | ACCESS Programming | EXCEL VB.Net Programming | EXCEL Spreadsheet Functions Material Management  |  Guestbook
 

ADO CopyTo Method

The CopyTo method is used to copy binary or text data from a source Stream object into a destination Stream object. Both Stream objects must be open or an error will be generated. Ideally, the type (text or binary) of both the source and destination Stream objects should be the same. However, you can copy a text Stream object into a binary Stream object, but not vise-versa. The default is to copy all data from the current position to the end of the stream (EOS).

If there is existing data in the destination Stream object, it may not necessarily be completely overwritten during the copy. If the source copy data is smaller in size than the existing data at the destination, then the existing data that extends beyond the end of the copy will not be overwritten and will remain in the destination Stream.

This method has one mandatory and one optional parameter.

You can set the CharSet property of the destination Stream object to be different than the source and the text will be appropriately translated.

Syntax

objStream.CopyTo dest,numchars

 
Parameter

Description

destination Required. Where to copy the Stream (contains a reference to an open Stream object)
numChars Optional. An integer that specifies the number of characters or bytes to be copied from the current position in the source Stream to the destination Stream. Default is -1 (will copy all data from the current position to EOS)

Note: If the specified number is greater than the available number of bytes/characters until EOS, then only bytes/characters from the current position to EOS are copied

Syntax


objMeditationStream.CharSet = "ascii"
objGuruStream.CopyTo objMeditationStream