Tag Archives: adodb

ADODB and disconnected recordset

I needed to look for a good way to sort an input CSV file via vbScripts. One of it is to use a bubble sort, but it does not give me added flexibiltiy to manipulate each record in the CSV file and I didn’t really want to work on arrays.

Then I remember reading something about disconnected recordset and did a quick search and found Goodbye Array… hello Disconnected DataSet! among some other similar articles.

“Great!”, I thought to myself: “Let find out more about ADOR”. I spent 1-2 hours googling for this and could not find any actually references to it, even in MS MSDN sites, all I’ve got is ADODB instead. A bit later, I found out that ADOR is actually an outdated object and ADODB is the way to go.

So I did some search on ADODB and disconnected recordset. Most of the results returned are about how to disconnect your ADODB connection from a database, nothing about using it just to replace our good old array, to do simple sorting. So I guess I need to get the old ADOR scripts updated here:

Const adVarChar = 200 ‘String variable
Const MaxCharacters = 255

Set rs = WScript.CreateObject(“ADODB.recordset”)

rs.Fields.Append “Field1”, adVarChar, MaxCharacters
rs.Fields.Append “Field2”, adVarChar, MaxCharacters

‘you can added record like this

rs.fields.item(“Field1”) = “TEST1”
rs.fields.item(“Field2”) = “This is a test”

‘or like this

rs.fields.item(0) = “ATEST2”
rs.fields.item(1) = “This is another test”

rs.Sort = “Field1”

Do Until rs.EOF

Wscript.Echo rs.Fields.Item(“Field1”) & vbTab & rs.Fields.Item(“Field2”)


‘ Release the recordset.
Set rs = Nothing


Posted by on April 25, 2007 in Scripts, VBScripts


Tags: ,