They say you learn something new every day.

Posts tagged ‘ado’

Stringing it out (19/02/2012)

So, everyone knows string concatenation is bad. And by everyone, I mean everyone who understands vbscript or ASP and then me.

However, even though I’ve always known it’s bad, I haven’t really seen a way around it, without writing an array and constantly re-diming it. Which is… well, a mess really.

However, I came across the ADO textstream function the other day that allows you to do something like this:

Set Stream = CreateObject(“ADODB.Stream”)
Stream.Type = 2
Stream.Open

’ This is where you put your loop

Stream.WriteText “test”
Stream.WriteText “test2”

’ End your loop here

Stream.Position = 0

Value = Stream.ReadText()

It’s surprisingly concise. Now, maybe, in some circumstances, there is a quicker way than this. But that requires a complex extra function, whereas this is so neat.

Time to go back and rewrite some things, I think.

Tag Cloud