Database
  Home arrow Database arrow Page 3 - ADO`s Stream Object
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
eWeek
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

ADO`s Stream Object
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2006-09-19

    Table of Contents:
  • ADO`s Stream Object
  • How to open a Stream object using ADO
  • Syntax for opening a Stream
  • Opening a Stream using an open Record Object
  • Opening a Stream using an URL reference
  • Opening a Stream with no argument, Memory Stream

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    ADO`s Stream Object - Syntax for opening a Stream
    (Page 3 of 6 )

    All arguments are optional as we discussed for the memory stream syntax for opening a Stream.

    Sub Open(
    [Source], 
    [Mode As ConnectModeEnum = adModeUnknown], 
    [Options As StreamOpenOptionsEnum = adOpenStreamUnspecified], 
    [UserName As String], 
    [Password As String]
    )

    Record opens with an open recordset and Stream uses the open Record

    As mentioned in the introduction, the Stream object may be opened using an open Record object. We have seen in an earlier tutorial that the Record object may open using a recordset object. This is the case we will be considering here. We look at most of the properties for this example, but we will only look at a couple of properties in other cases, as they are not going to vary.

    Place a command button on an MS Access form and use the following code in the click event of the command button. The comments before the statement provide enough information to understand the code.

    Private Sub Command0_Click()
    'declare the there objects
    Dim rec As ADODB.Record
    Dim rst As ADODB.Recordset
    Dim strm As ADODB.stream
    'instantiate the record and recordset
    Set rec = New ADODB.Record
    Set rst = New ADODB.Recordset
    'open recordset, must use URL= as shown
    rst.Open "", "URL=http://hodentek/"
    If rst.State = adStateOpen Then
    MsgBox ("Recordset is Open")
    End If
    'use the open recordset to open the record
    rec.Open rst
    If rec.State = adStateOpen Then
    'MsgBox ("Record is open")
    End If
    'instantiate the stream object
    Set strm = New ADODB.stream
    'open the stream using the open record
    strm.Open rec, , adOpenStreamFromRecord
    If strm.State = adStateOpen Then
    'MsgBox ("Stream is Open")
    End If
    '---interrogate properties of stream--
    Dim str As String
    str = "---Stream Object Properties---" & vbCrLf & vbCrLf
    str = str + "Stream.Charset: " & strm.Charset & vbCrLf & vbCrLf
    str = str + "Stream.EOS: " & strm.EOS & vbCrLf & vbCrLf
    str = str + "Stream.Line Separator: " & strm.LineSeparator & vbCrLf & 
    vbCrLf
    str = str + "Stream.Mode:           " & strm.Mode & vbCrLf & vbCrLf
    str = str + "Stream.Position:       " & strm.Position & vbCrLf & vbCrLf
    str = str + "Stream.Size:           " & strm.Size & vbCrLf & vbCrLf
    str = str + "Stream.Type:           " & strm.Type & vbCrLf & vbCrLf
    str = str + "Stream.State:          " & strm.State & vbCrLf & vbCrLf
    Text1.SetFocus
    Text1.Text = str
    strm.Close
    rec.Close
    rst.Close
    End Sub

    While typing in the code do not forget to use the intellisense support for coding as the next picture shows while choosing what to do next. It's the multiple choice paradigm all over!

    When this form is displayed we can see all the properties of the Stream object. However the values of these properties appear as numbers. These numbers are enumerated values of Constants in ADO whose description may not be available. In the drop-down cues you will find these constants. A good reference where you may find these constants listed is in the book Programming ADO (author David Sceppa; year published: 2000; ISBN: 0-7356-0764-8).


    The meanings of the numeric constants are provided in the next paragraph.

    Constants:

    Meaning:

    EOS:

    false means the current position in the stream is not the end.

    Line Separator:

    -1 means carriage return & line feed will be used in text (vbCRLF)

    Mode:

    1 means Read Only permission (default); there are seven such enums

    Position: 

    0 means current position is at the beginning of data

    Size: 

    1130,  Size of the stream in bytes

    Type: 

    type of data stored in stream, value 2 means Text (default)

    state: 

    stream is open, or closed, 1 is open 0 is closed.

    More Database Articles
    More By Jayaram Krishnaswamy


       · There will be a follow up article that shows you how to manipulate the web files on...
     

    DATABASE ARTICLES

    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client
    - ADO`s Stream Object
    - Opening a Record Object Referencing an Open ...
    - Introducing Jasper (SQL Anywhere 10 Beta)
    - Creating a Database Project in VS 2005
    - Manipulating ADO Recordsets




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway