ADO Stream Object Properties

[Previous] [Next]

Here's a list of the properties available on the Stream object.

Stream Object Properties
Property NameData TypeDescription
CharsetStringSpecifies the character set for the text stream
EOSBooleanIndicates whether the current position is at the end of stream (EOS)
LineSeparatorLineSeparatorEnumSpecifies the character or combination of characters used as the line separator in the text stream
ModeConnectModeEnumIndicates the permissions for modifying data in the Stream object
PositionLongSpecifies the current position in the stream
SizeLongIndicates the size of the stream of data
StateObjectStateEnumIndicates the current state of the Stream object
TypeStreamTypeEnumIndicates the type of data stored in the Stream object

Charset Property

The Charset property contains a string that specifies the character set used to store string data in the Stream. You can set this property to any of the registered character sets available in your local registry under the key HKEY_CLASSES_ROOT\MIME\Database\Charset. The Stream object's Position property must be set to 0 before you can set the Charset property. If the Stream is set to store binary data, this property is ignored.

The Stream object stores text data in Unicode format, no matter what the value of the Charset property is. If you're going to work with text data that uses a different character set, you should set the Charset property to reflect that character set so ADO can translate the data to the correct format as it's read into and out of the Stream object. Say you're working with ANSI data and you want to store that data in a Stream object and then save it to a file. If you leave the Charset property with its default setting, the data will be saved to the text file in Unicode format. However, you can set the Charset property to the appropriate character set so your data will be stored to the text file in the desired format. For example, if you want to specify that you're using ANSI data, set the Charset property as shown here:

 Stream.Charset = "iso-8859-1" 

Remember that this property affects how ADO accepts and returns string data, so you're best off setting this property when the Stream object is closed. You can modify the Charset property after you've already stored text in your Stream, but this will only affect how ADO translates the string data when it's returned.

EOS Property

The EOS property is similar to the EOF property on the Recordset object. It stores a Boolean value that indicates whether you're positioned at the end of the data stored in the Stream object. You can call the SetEOS method to denote the end of the data.

LineSeparator Property

Use the LineSeparator property on the Stream object to control the character or characters that ADO will use to separate lines of text. This value can be set to any of the values available in LineSeparatorEnum, shown in the following table. You can set the LineSeparator property on the Stream object at any time, regardless of whether the Stream is open or closed.

LineSeparatorEnum Values
ConstantValueDescription
adCRLF-1Default; a combination of the carriage return and line feed characters will be used to separate lines of text.
adLF10The line feed character will be used to separate lines of text.
adCR13The carriage return character will be used to separate lines of text.

Mode Property

The Mode property indicates the permissions for modifying the Stream object. This property contains a long value that represents a bitmask of values in ConnectModeEnum. (See "Mode Property" under the Record object discussion earlier in this chapter for a list of values.) The Stream object's Mode property functions similarly to the Record object's Mode property.

Position Property

The Position property contains a long value that specifies the current byte position (0-based) in the stream of data. This property is read/write while the Stream object is open. If you attempt to check the Position property on a closed Stream, you'll receive a run-time error.

When using a Stream to store Unicode data or other multibyte string data, be sure to set the Position property to an even number because each character uses 2 bytes of space.

Size Property

The Size property is read-only and returns a long value that indicates the size, in bytes, of the data stored in the Stream object. Checking the value of this property on a closed Stream will generate a run-time error. The Size property will return -1 if the data in the Stream object is an undetermined size. If the data is too large to be stored in a long integer, the Size property will be truncated.

State Property

The Stream object's State property has the same functionality for a Stream object as the Record object's State property has for a Record. See "State Property" under the Record object discussion earlier in this chapter for a description of the State property and its possible values.

Type Property

The Type property indicates the type of data stored in the Stream object. This property will take one of the values in StreamTypeEnum, as listed in the following table. You can set the Type property on a closed Stream object or on an open Stream object whose Position property value is 0.

StreamTypeEnum Values
ConstantValueDescription
adTypeBinary1The Stream object contains binary data.
adTypeText2Default; the Stream object contains text data.


Programming ADO
Programming MicrosoftВ® ADO.NET 2.0 Core Reference
ISBN: B002ECEFQM
EAN: N/A
Year: 2000
Pages: 131
Authors: David Sceppa

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net