Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 26th, 2004, 01:32 PM
Registered User
 
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default objStream to open a file

I have been trying to use objStream to write to a file but have been getting all kinds of errors.

The file is stream.txt and is located in the folder http://localhost/7/

I am trying to open it from a page (shipStream.asp) in the same directory.....

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open "URL=http://localhost/7/stream.txt", adModeRead, adOpenStreamFromURL

This gives me:
Error Type:
(0x80040E96)
/7/shipStream.asp, line 20

I have tried the same omitting 'URL=' (ala example pg 623 Beg.ASP 3) and this returns the error:

ADODB.Stream (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/7/shipStream.asp, line 20

What am I doing wrong!? It's probably something stupid..I don't care, I just want to get on developing!

Regards Guy




 
Old July 26th, 2004, 01:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Do you have these values defined as constants in your code:

adModeRead, adOpenStreamFromURL

Brian
 
Old July 26th, 2004, 06:59 PM
Registered User
 
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian,

I read your reply and thought 'Doh!' because I had forgotten to include the path to msado15.dll

So I included the following


and.....got exactly the same errors again.... :(

if I use direct values i.e. objStream.Open "http://localhost/7/stream.txt" , 1 , 8

it doesn't help either....I am sure it's something stupid I've done!

By the way I've just used scripting.FSO to achieve what I want and it works fine. Which is better?

regards, Guy


 
Old July 27th, 2004, 08:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I like Scripting.FileSystemObject personally, thought I don't know which is better. I just personally like it.

Try without declaring an http maybe; try with the path to a file. I don't know if it can open those kinds of locations?

Brian
 
Old August 2nd, 2004, 05:46 PM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this:
 objStream.Open
 objStream.LoadFromFile "C:\7\Stream.txt"
 strText = objStream.ReadText

provided that is the correct path. It worked for me.
Ken
 
Old August 3rd, 2004, 08:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Guy,

Each has its own merits and demerits. You got to use that depending on the what you would like to do. Somethings are common among these two objects (like file data handling). With stream object you can read the binary data(of image file) and display that on your page. But I beleive FSO doesn't let you do that.

You can take a look at these tow links.
Stream object

FileSystemObject Object

objStream.Open source,<other params>
where SOURCE is Optional. The data source for the Stream object (a URL that points to an existing node in a tree structure, like an e-mail or file system or a reference to an already opened Record object). If source is not specified, a new Stream object, with a size of zero, will be created and opened

Not sure, if this internally uses filesystemobject to do things.

BTW, where does that text file that you are trying to access reside?
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open up a flat file daniel_arney Beginning VB 6 1 September 27th, 2006 02:40 PM
Open the "Open File" dialogue box piratelordx Access VBA 4 March 14th, 2006 10:08 PM
Cannot open include file pedromecanica Visual C++ 4 February 14th, 2005 04:55 PM
How to open a file in c#? looooly C# 3 September 25th, 2004 03:39 AM
open the file altafingar Classic ASP Databases 3 August 26th, 2004 07:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.