We help IT Professionals succeed at work.

ADODB Stream - WriteText/ReadText

Corrup7ioN
Corrup7ioN asked
on
11,556 Views
Last Modified: 2010-04-21
Hopefully this will be a nice easy question.

I'm trying to use an ADODB Stream to concatenate several strings and eventually save the stream to file. I've never used a stream before, but it looked fairly easy, so I went ahead and made a quick test (see code snippet).

To be perfectly honest, I expected that to work without any problems, but I'm getting quite frustrated now as I can't seem to get something that seems incredible simple to work. Its obvious from my code what its supposed to be doing, but its just not working. No text is being written to the response object, yet there is no error.

I'm guessing that I overlooked some obscure yet obvious setting or something or have misunderstood the functions, could someone please put me out of my misery?

Thanks
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
			
objStream.open
objStream.WriteText("hello")
			
response.Write(objStream.ReadText)
 
objStream.close

Open in new window

Comment
Watch Question

Commented:
After you've written the text to the stream, you need to read it into a variable in order to write it:

Dim objStream, strOutput
Set objStream = Server.CreateObject("ADODB.Stream")
                  
objStream.open
objStream.WriteText("hello")
'reads number of characters or adReadAll = -1, adReadLine = -2
strOutput = objStream.ReadText(adReadAll)    
response.Write(strOutput)
 
objStream.close


Cheers,
Scott

Author

Commented:
I believe I tried that, but will give it another go. Can't try until Monday though.

Thanks for the reply

Author

Commented:
I'm sorry to say that this isn't working. The code snippet shows exactly what code I have. When I read from the stream into the variable data, the variable is just empty. I checked with len in case the characters were not being drawn properly, but the length is 0.

Any ideas as to what might be going on?

Dim objStream
Set objStream= CreateObject("ADODB.Stream")	
 
objStream.Open
			
objStream.WriteText("hello")
data = objStream.ReadText(-1)		
			
response.write "-" & data

Open in new window

Author

Commented:
Anyone?
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Wow thank you! Such a simple solution! I'd pretty much given up all hope on this.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.