ADO`s Stream Object - Opening a Stream using an URL reference (Page 5 of 6 )
It is not necessary to have a record open to open a Stream object. By providing a URL reference the Stream may be opened as shown in the next code listing.
Private Sub Command0_Click()
Dim strem As ADODB.stream
Set strem = New ADODB.stream
strem.Open "URL=http://hodentek/testing.txt/"
Debug.Print ("strem.Type: " & strem.State) & vbCrLf
Debug.Print ("strem.Size: " & strem.Size) & vbCrLf
Debug.Print ("strem.EOS: " & strem.EOS) & vbCrLf
Debug.Print ("strem.state: " & strem.State) & vbCrLf
strem.Close
End Sub
The next listing shows the print out from the debug.print statements.
strem.Type: 1
strem.Size: 5271
strem.EOS: False
strem.state: 1
You may be wondering why in spite of the resource being of type 'text,' ADO returns a value for type= 1. In fact this has appeared in a large number of FAQs and caused confusion. If you open a text directly into Stream (no other object is open except the Stream), Microsoft says (not in small print) that the initial data will be shown as binary! This means that the value for Type=1.
Next: Opening a Stream with no argument, Memory Stream >>
More Database Articles
More By Jayaram Krishnaswamy